I am trying to create an archive as:

tar -Jcvf shadow-2.7.1.tar.xz shadow/ --exclude-vcs

and I am expecting no .git folder. But

vi shadow-2.7.1.tar.xz 



Mu system is:

which tar
tar --version
tar (GNU tar) 1.29
uname -sr
Linux 4.9.6-200.fc25.x86_64

What is going wrong here?

  • The options should come before the files. tar -Jcvf --exclude-vcs shadow-2.7.1.tar.xz shadow/ should do the job. – Jakuje Jan 29 '17 at 16:37
  • @don_crissti sure. But the point is hopefully clear. – Jakuje Jan 29 '17 at 18:36
  • @Jakuje Have you tested this? With tar 1.27.1, the location of the option doesn't matter. Has this changed in more recent versions? – Gilles 'SO- stop being evil' Jan 29 '17 at 23:23
  • @Gilles. No, i didnt test it, since it was more like guess and leaving something to the OP. Though thanks for good answer with deeper analysis. – Jakuje Jan 30 '17 at 6:35

Your command works up to GNU tar 1.28. But in version 1.29, the command line parsing mechanism changed. Before, the order of options and operands didn't matter. In recent versions, the order does matter: options that determine which files are selected are position-sensitive and only apply to operands that follow.

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.