I want to compress a directory in Linux. I created a tar.gz that it turns to be a big file, due to the reason that the directory contains some *.o files and some pdf files.
Is there any way to compress a directory but exclude files larger than a predefined SIZE? There is a --exclude argument in tar command, however I would like to reject files larger than 1 MB. This is the constrain, not the name of the file.
Based on Jan-Philip Gehrcke's response:
find . -type f -size -1024k -print0 | tar -czf --null -T - -f archive.tar.gz
for files less than 1M. Tested on OS X and Ubuntu Linux.
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