Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer

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

share|improve this answer
    
How do you uncompress all the files later? –  Xeoncross Dec 17 '12 at 17:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.