Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run tar command - invalid option -- '▒'

I've run into a problem while running a tar script. I am getting an invalid option, as shown in the screenshots, that is stopping the script running. I don't get why however as the command worked outwith the script. Can anyone help me?

The script:

The script

The error:

The error

like image 720
Angus Avatar asked Apr 29 '16 11:04

Angus


2 Answers

Are you copy and pasting the command, instead of hand-typing it in terminal?

In my case, I was getting:

tar: invalid option -- '�'

I was pasting into terminal, the command from a raw text file, which I had copied from a tutorial:

tar –xvzf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz

I hand-typed the entire command:

tar -xvzf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz

and it worked. I suspect it was something like an extra space character or a - or similar which was not working.

like image 101
Tropicalrambler Avatar answered Oct 23 '22 13:10

Tropicalrambler


Thanks to Paul R I have an answer. No idea how to mark his comment as the answer though so here it is:

Some older versions of tar don't like the - at the start of the commands - try tar cvpfz .... – Paul R 5 mins ago

like image 18
Angus Avatar answered Oct 23 '22 13:10

Angus