I'm trying to run a tar command and I keep getting this odd error.

The command:

  tar ./files.tar -C $HOME

And I get this in return:

 Error: tar: invalid option -- '.'

My files.tar folder is located correctly near my script and contains some directories.

Any ideas?


Add the options before the file name and so:

tar -xf files.tar -C $HOME
  • This just returns another error: tar: "C: Cannot open: No such file or directory" – Wolfyaskingstuff Oct 16 '17 at 11:55
  • Are you trying to extract the tar file files.tar? – Raman Sailopal Oct 16 '17 at 11:56
  • 2
    The order of x and f must match the order of the arguments they are referring to. So tar xfC files.tar $HOME. – Johan Myréen Oct 16 '17 at 11:57
  • Yes I am. But extract them in the home directory. – Wolfyaskingstuff Oct 16 '17 at 11:57
  • @JohanMyréen That worked! – Wolfyaskingstuff Oct 16 '17 at 11:59

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.