I have some files that I want to copy from one directory to another with a shell script but I only want to copy the ones that have something in them. Right now this is what I have but it won't check to make sure that the files aren't empty. cp -f /some/folder/* /another/folder/
Is there an easy way to do this?
You can use find
command for this:
find . -type f -size +0 -print0 | xargs -0 -I % cp % /dest/
-size +0
will get files with size greater than zero.
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