Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Noob alert:

Can I exclude files in the directory "imagecache" but still make the directory a part of the TAR archive?

share|improve this question
up vote 0 down vote accepted

Certainly, just use --exclude for that purpose.

tar czf file.tar.gz --exclude '*/imagecache/*' files-or-directories-to-add

man tar

share|improve this answer
Just to be sure, will there still be the a empty directory called "imagecache" in the archive? – Cudos Mar 17 '11 at 18:34
Yes, I've used this command yesterday. I've just tested this command, and it still works. – Lekensteyn Mar 17 '11 at 18:35

Your Answer


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.