Super User is a question and answer site for computer enthusiasts and power users. 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

I want tar a direcory which contains a number of child directories. But here my requirement is to tar the entire parent direcory excuding one child directory.

Is there any command or procedure for this.

Thanks in advance.

share|improve this question

migrated from Apr 30 '13 at 8:06

This question came from our site for professional and enthusiast programmers.

Tar exclude doesn't exclude why – Abdullah Shoaib Apr 30 '13 at 5:36


tar -zcvf foo_out.tar.gz --eclude bar foo_dir/

this really belongs in another stackexchange forum.

(from mobile)

share|improve this answer

Say if the parent directory is called parent and the directory to be excluded is child, you can try the following:

find parent \( ! -wholename "*child*" \) | cpio -ov --format=ustar > outfile.tar
share|improve this answer

Try This One , this creates your tar with excluding some folders or files

tar -czf filename.tar.gz pathToParentFolder --exclude=pathToParentFolder/childrenFolder

share|improve this answer

Your Answer


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