码迷,mamicode.com
首页 > 其他好文 > 详细

which命令

时间:2016-05-13 03:10:29      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

which命令用于查找并显示给定命令的绝对路径,环境变量PATH中保存了查找命令时需要遍历的目录。which指令会在环境变量$PATH设置的目录里查找符合条件的文件。也就是说,使用which命令,就可以看到某个系统命令是否存在,以及执行的到底是哪一个位置的命令。

语法:

which (选项) (参数)
选项:
-n<文件名长度>:制定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名;
-p<文件名长度>:与-n参数相同,但此处的<文件名长度>包含了文件的路径; 
-w:指定输出时栏位的宽度; 
-V:显示版本信息。
参数:
指令名:指令名列表。
实例:

查找文件、显示命令路径:

XXXXXX:/ GavinPSU$ which whereis
/usr/bin/whereis
XXXXXX:/ GavinPSU$ which pwd
/bin/pwd
XXXXXX:/ GavinPSU$ 


===BSD General Commands Manual ===== 


NAME

     which -- locate a program file in the user‘s path


SYNOPSIS

     which [-as] program ...

DESCRIPTION

     The which utility takes a list of command names and searches the path for

     each executable file that would be run had these commands actually been

     invoked.


     The following options are available:

     -a      List all instances of executables found (instead of just the first one of each).

     -s      No output, just return 0 if any of the executables are found, or 1 if none are found.


     Some shells may provide a builtin which command which is similar or identical to this utility.  Consult the builtin(1) manual page.


SEE ALSO

     builtin(1), csh(1), find(1), locate(1), whereis(1)


HISTORY

     The which command first appeared in FreeBSD 2.1.


AUTHORS

     The which utility was originally written in Perl and was contributed by Wolfram Schneider <wosch@FreeBSD.org>.  The current version of which was rewritten in C by Daniel Papasian <dpapasia@andrew.cmu.edu>.


关于linux/unix的更多讨论与交流,敬请关注本博和新浪微博songzi_tea.

which命令

标签:

原文地址:http://blog.csdn.net/songzitea/article/details/51339325

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!