nitin_cherian
nitin_cherian

Reputation: 6655

Exclude directory while compressing using tar

I have a directory say "DIR" which contains so many directories say "A", "B" and "C"

I want to tar DIR without including "C" in it so that DIR.tar.gz does not contain the directory "C".

What is the shell command for this?

Thanks, LinuxPenseur

Upvotes: 0

Views: 962

Answers (2)

Raghuram
Raghuram

Reputation: 3967

Try this

tar --exclude="C" -czvf D.tar.gz DIR

Upvotes: 1

cdhowie
cdhowie

Reputation: 168958

Depending on your command line, something like this:

tar -cf archive.tar --exclude C DIR

Also, to nitpick your question, tar does not perform compression.

Upvotes: 2

Related Questions