6

I ran the following in Debian 9.3:

cd /usr/local/src
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz

The file was downloaded just fine, and yet, when I execute:

tar -xzfv maldetect-current.tar.gz

I get:

tar (child): v: Cannot open: No such file or directory tar (child):
Error is not recoverable: exiting now tar: Child returned status 2
tar: Error is not recoverable: exiting now

But ls -la shows that the file does indeed exist:

/usr/local/src# ls -la
total 3144
drwxrwsr-x  2 root staff    4096 Jan  8 11:46 .
drwxrwsr-x 11 root staff    4096 Jan  8 11:40 ..
-rw-r--r--  1 root staff 1605546 Jul 14 04:45 maldetect-current.tar.gz
12

The filename should follow immediately after the f option.

tar -xzvf maldetect-current.tar.gz
29

You got caught in a trap. tar supports two formats of command line options, the usual one with a dash, and the legacy format without one. And they differ with regard to argument handling.

Here:

tar -xzfv maldetect-current.tar.gz

the argument for -f is v, as in about all other tools.

On the other hand, here:

tar xzfv maldetect-current.tar.gz

the argument to f is taken from the next command line argument, the filename you actually wanted to give.

The error message mentions the filename it tried to access, you might just have missed it since v is rather short. Usually the file in question is listed in error messages, though.

The GNU tar man page mentions this under "Option styles":

In traditional style, the first argument is a cluster of option letters and all subsequent arguments supply arguments to those options that require them.

In UNIX or short-option style, each option letter is prefixed with a single dash, as in other command line utilities. If an option takes argument, the argument follows it, either as a separate command line word, or immediately following the option.

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.