我在 Debian 9.3 中运行了以下命令:
cd /usr/local/src
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
Run Code Online (Sandbox Code Playgroud)
该文件下载得很好,但是,当我执行时:
tar -xzfv maldetect-current.tar.gz
Run Code Online (Sandbox Code Playgroud)
我得到:
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
Run Code Online (Sandbox Code Playgroud)
但ls -la
表明该文件确实存在:
/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
Run Code Online (Sandbox Code Playgroud)
ilk*_*chu 29
你陷入了陷阱。tar
支持两种格式的命令行选项,通常的一种带有破折号,一种没有一种的旧格式。它们在参数处理方面有所不同。
这里:
tar -xzfv maldetect-current.tar.gz
Run Code Online (Sandbox Code Playgroud)
的论点-f
是v
,就像所有其他工具一样。
另一方面,这里:
tar xzfv maldetect-current.tar.gz
Run Code Online (Sandbox Code Playgroud)
to 的参数f
取自下一个命令行参数,即您实际想要提供的文件名。
错误消息提到了它试图访问的文件名,您可能只是错过了它,因为v
它很短。不过,通常有问题的文件会列在错误消息中。
在GNU焦油手册页提到了这一点在“选择样式”:
在传统风格中,第一个参数是一组选项字母,所有后续参数为需要它们的选项提供参数。
在 UNIX 或短选项样式中,每个选项字母都以一个破折号作为前缀,就像在其他命令行实用程序中一样。如果选项接受参数,则参数跟随它,作为单独的命令行单词,或紧跟在 option 之后。
Ger*_*lle 12
文件名应该紧跟在 f 选项之后。
tar -xzvf maldetect-current.tar.gz
Run Code Online (Sandbox Code Playgroud)