which (查找可执行文件)

EE 发表于 2020-08-24 17:14
浏览次数:
在手机上阅读

在类似Unix的操作系统上,which命令查找与给定命令关联的可执行文件。

查看英文版

目录

1 which 运行系统环境

2 which 说明

3 which 语法

4 which 例子

which 运行系统环境

Linux

which 说明

返回将在当前环境中执行的文件(或链接)的路径名,如果文件名(或文件名s)在严格POSIX-符合的 shell 中作为命令(或命令)提供。它通过搜索 PATH 环境变量中的路径来搜索与参数名称匹配的可执行文件。
不遵循符号链接。

which returns the pathnames of the files (or links) which would be executed in the current environment, had the filename (or filenames) been given as a command (or commands) in a strictly POSIX-conformant shell. It does this by searching thepathsin the PATH environment variable for executable files matching the names of the arguments.
which does not follow symbolic links.

查看英文版

查看中文版

which 语法

which -a [filename] ...

选项

-a 打印每个匹配文件名的所有匹配路径名。

Exit Status

返回以下值,具体取决于发生了什么:


0 找到所有文件名,并且所有文件名都是可执行文件。
1 未找到一个或多个文件名,或不可执行。
2 指定了无效选项。
which -a [filename] ...

Options

-a Print all matching pathnames of each matching filename.

Exit Status

which returns the following value, depending on what occurred:

0 All filenames were found, and all were executable.
1 One or more filenames were not found, or were not executable.
2 An invalid option was specified.

查看英文版

查看中文版

which 例子

which sh

查找执行sh命令时将运行的文件的路径名。在大多数系统上,这输出:

/bin/sh
which sh

Locates the pathname of the file which would be run if the sh command were executed. On most systems, this will output:

/bin/sh

查看英文版

查看中文版

其他命令行

whereis | write | wc | w | whatis | who | whoami | whois | wait | wall |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条