At the linux command line, I'd like to compress all .pdf files in a directory, any of it's subdirectories and so on - but only .pdf files. I'm struggling to figure out the syntax, any ideas appreciated.
Asked
Active
Viewed 3,254 times
2 Answers
2
PDF files are binary files and probably won't compress much. tar doesn't compress anyway, without the -z option, and it would leave the uncompressed PDF files in place.
But if you want to try compressing PDF files, you could use
find . -iname '*.pdf' -exec gzip {} \;
This will compress all PDF files (and only PDF files) in folders below the current directory.
Each filename.pdf will be replaced by filename.pdf.gz
pavium
- 6,490