The example below shows how you can exclude file “somefile.txt” and directory “subfolder6” from the tar command:
cd /myfolder echo "subfolder1/somefile.txt" > tarex.tmp echo "subfolder2/subfolder5/subfolder6" >> tarex.tmp tar cvfX mytarfile.tar tarex.tmp subfolder1 subfolder2 subfolder3 rm tarex.tmp