Den*_*aia 154
学习whereis
和which
使用whatis
怎么样?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Run Code Online (Sandbox Code Playgroud)
基本上,whereis
搜索“可能有用”的文件,而which
只搜索可执行文件。
我很少用whereis
。另一方面,which
非常有用,特别是在脚本中。which
是以下问题的答案:此命令从何而来?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
Run Code Online (Sandbox Code Playgroud)
小智 27
whereis
搜索指定命令的标准 *nix 位置。
which
搜索特定于用户的 PATH(可能包括 whereis 搜索的一些位置,可能不包括其他位置 -whereis
如果您已添加到 PATH ,它还可能包括一些不搜索的位置)
小智 6
引用他们的手册页:
哪里:
whereis 定位指定文件的源/二进制和手册部分。
例如 :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
Run Code Online (Sandbox Code Playgroud)
即,“php”可执行文件和其他一些东西(如手册页)。
并且其中:
它返回将在当前环境中执行的文件的路径名
例如 :
$ which php
/usr/bin/php
Run Code Online (Sandbox Code Playgroud)
即,只有“php”可执行文件。
归档时间: |
|
查看次数: |
43534 次 |
最近记录: |