0

Unix中的whereand命令有什么区别?which

4

3 回答 3

1

免责声明:这是在使用 cygwin 的 windows 框中。

Which显示一个可执行文件的完整路径,Where可以显示多个。

$which git sh

会产生类似于/bin/git/传递的第一个 arg 的相对路径的东西,但是,

$where git sh

为传递的所有参数生成绝对路径,即注意我在一个 windows 盒子上,所以我得到了一些效果

C:\Program Files (x86)\Git\bin\git.exe
C:\Program Files (x86)\Git\cmd\git.exe
C:\Program Files (x86)\Git\bin\sh.exe

要添加到其他答案,我认为仅存在于 Windows 中。

于 2013-02-07T13:48:47.257 回答
1

你的意思是在哪里?它只是找到二进制文件,而 wehereis 也试图找到源代码和手册页。

于 2013-02-07T13:34:34.737 回答
1

“where”似乎不是一个常见的 unix 命令,我找不到任何手册页。

然而,“哪里”确实存在于大多数 Windows 操作系统中。

查看上述链接。

WHERE (Windows 2003 + )

Locate and display files in a directory tree. 

The WHERE command is roughly equivalent to the UNIX 'which' command. 
By default, the search is done in the current directory and in the PATH.

这是有道理的,因为“which”的手册页指出:

WHICH(1)

NAME
   which - shows the full path of (shell) commands.

你在使用 Cygwin 吗?

我问是因为这将是“哪个”和“哪里”都存在于同一环境中的最常见情况。

在那种环境中,“which”将以类似 unix 的方式显示命令所在的路径。

$ which where
/cygdrive/c/Windows/system32/where

而“where”将以类似窗口的方式显示路径。

$ where which
C:\cygwin\bin\which.exe
于 2013-02-07T13:45:41.423 回答