Answers:
检查您的路径。最终得到重复并不难。例:
»echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:
»which -a bash
/bin/bash
/usr/bin/bash
这是因为我的/ bin是/ usr / bin的符号链接。现在:
»export PATH=$PATH:/usr/bin
»echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/bin
»which -a bash
/bin/bash
/usr/bin/bash
/usr/bin/bash
由于/ usr / bin现在在我的$ PATH中两次,which -a
因此两次查找相同的bash。
如提示所述,并从手册页引述,"Which takes one or more arguments. For each of its arguments it prints to stdout the full path of the executables that would have been executed when this argument
had been entered at the shell prompt. It does this by searching for an executable or script in the directories listed in the environment variable PATH using the same
algorithm as bash(1)."
至于该-a
选项,它按$ PATH中的名称列出了所有可执行文件。