我对 ubuntu 真的很陌生,我无法理解有关终端反馈的内容。
课程书说,当您为“which”实用程序指定搜索路径中不存在的命令名称时,应该会收到来自终端的反馈。
但是,当我故意这样做时,绝对没有任何反应。请参阅此处: 使用明显不执行任何操作的命令根本没有任何反馈
有谁知道我如何让终端向我提供错误反馈?
which从未在命令行上显示错误消息。至少不是在 Debian 版本的 Linux 上。每个系统似乎都有自己的版本(这是首选其他命令的原因之一),所以也许您的课程引用了另一个操作系统?对于在脚本中使用,您可以有 3 种退出状态:
EXIT STATUS
0 if all specified commands are found and executable
1 if one or more specified commands is nonexistent or not executable
2 if an invalid option is specified
Run Code Online (Sandbox Code Playgroud)
使用type、whatis、 或whereis。所有 3 项都将显示它没有找到您要求的内容。
$ type aaa
bash: type: aaa: not found
$ whereis aaaa
aaaa:
$ whatis aaaa
aaaa: nothing appropriate.
Run Code Online (Sandbox Code Playgroud)
和
type firefox
firefox is /usr/bin/firefox
$ whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox
/usr/share/man/man1/firefox.1.gz
$ whatis firefox
firefox (1) - a free and open source web browser
from Mozilla
Run Code Online (Sandbox Code Playgroud)
这是我们 U&L的一些历史。
| 归档时间: |
|
| 查看次数: |
730 次 |
| 最近记录: |