Ubuntu – Shell script to move all files from subfolders to parent folder

bashscripts

I've bunch of folders in folder A. I want to move files from all those folders to A.

Or

I want to cut all files from child folders and paste them in parent folder.

How to do that?

Best Answer

Go to your A directory and run

find . -mindepth 2 -type f -print -exec mv {} . \;

which means "find all files in this directory and its sub-directories and execute mv with target directory . for each file found to move them to current directory.