Linux: Compressing all .pdf files recursively (.tar)

Solution 1:

Try this: find -iname '*.pdf' -print0 | xargs -0 tar -cf docs.tar

Solution 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