Reputation: 13
While executing command in shell script like as follows i am getting an error please help
tar -xjf $tarfile
error is :
tar: option requires an argument -- f
Upvotes: 1
Views: 3969
Reputation: 26
Then the variable $tarfile is obiviously empty. Argument f
requires a filename or a hyphen to denote stdin allowing for piping of data to tar. The j
argument expects to find the tarfile compressed in bzip2 format.
In your script you would have to do something similar:
tarfile=/path/to/file.tar.bz2
tar -xjf $tarfile
or an example of piping:
ssh user@remotehost cat /path/to/file.tar.bz2|tar -xjf -
Upvotes: 1