So I have a slight problem…I unrared a crapton if files which are now all in their own directories and those directories are inside other directories.

Main/file1/file1unrared/file1.txt

So I want all those text file to just sit in Main not 2 dirs down from there.
If my current directory is Main, I can do this:

find . -type f -iname ‘*.txt’ -exec mv ‘{}’ . \; find . -type d -exec rm -rf ‘{}’ . \;

The above uses the find command to find all the txt files and run the mv command on them moving them to the current dir (Main)
Then, find is also used to find all the Directories, which are now empty, and delete them all using rm -rf

Very, very useful….

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.