Lakshmi Hayagreevan
Lakshmi Hayagreevan

Reputation: 13

Error in executing command tar -xjf

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

Answers (2)

stralle
stralle

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

Sjoerd
Sjoerd

Reputation: 75588

This happens because the $tarfile variable is empty.

Upvotes: 1

Related Questions