-a
中的标志非常which
有用。但是,我不确定它如何查找替代命令。有人能解释一下吗?它是否对命令名称进行部分字符串匹配?还是其他什么?
答案1
阅读手册页。在终端中写入man which
...
DESCRIPTION which returns the pathnames of the files (or links) which would be exe‐ cuted in the current environment, had its arguments been given as com‐ mands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.