Excluding certain folders in the tar command does not work… here is a solution to the problem.
Excluding certain folders in the tar command does not work
I run this command to compress the contents of the current folder while excluding some directories :
[email protected]:set3-HHLL$ l
file1.txt a/ c/
file2.inp b/ ...
[email protected]:set3-HHLL$ tar cvjf .. /set3.tar.bz2 * --exclude=a/ --exclude=b/ --exclude=c/
But in the output I see:
file1.txt
file2.inp
a/1.out
a/2.out
2/1.out
...
Why does it ignore command-line options?
Solution
The correct command is:
tar cvjf .. /set3.tar.bz2 * --exclude='a' --exclude='b' --exclude='c'