alvas
alvas

Reputation: 122052

Bash/Shell-Move all files from subdirectories into target directory?

How do I bash a command or a shell script to move all the files from the subdirectories to one target directory in Linux?

Upvotes: 9

Views: 11220

Answers (2)

thiton
thiton

Reputation: 36049

If you are using GNU mv, the -t option (target directory) is pretty useful:

find sourcedir -type f -print0 | xargs -0 mv -t target 

man mv gives more details.

Upvotes: 14

John P
John P

Reputation: 15245

Try something like this:

find sourcedir -type f -exec mv {} targetdir \;  

Upvotes: 8

Related Questions