1

I want to exclude two files from a tar file.. But it doesn't seem to work

cd /var/www/public/api_test
tar -zcvf api_v2.x.tar.gz api --exclude "./api/distributor_test.php" --exclude "./api/library/Distributor_API.php"
4
  • try putting api last (after options). – Archemar Sep 4 '15 at 9:37
  • no change in output – clarkk Sep 4 '15 at 9:38
  • 3
    tar -zcvf api_v2.x.tar.gz --exclude api/distributor_test.php --exclude api/library/Distributor_API.php api ? – Archemar Sep 4 '15 at 9:45
  • 1
    create an answer! :D – clarkk Sep 4 '15 at 9:53
3

try (in one line, I fold for readability)

tar -zcvf api_v2.x.tar.gz 
   --exclude api/distributor_test.php 
   --exclude api/library/Distributor_API.php api
  • argument (e.g. api) should be put last
  • you may use --exclude distributor_test.php (if you only have one file named distributor_test.php )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.