How do I bash a command or a shell script to move all the files from the subdirectories to one target directory in Linux?
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.
Try something like this:
find sourcedir -type f -exec mv {} targetdir \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With