我检查目录ls -l /usr/local/opt/coreutils/libexec/gnubin
并附带
$ ls -l /usr/local/opt/coreutils/libexec/gnubin
total 0
lrwxr-xr-x 1 me admin 12 Oct 27 12:50 '[' -> '../../bin/g['
lrwxr-xr-x 1 me admin 16 Oct 27 12:50 b2sum -> ../../bin/gb2sum
lrwxr-xr-x 1 me admin 17 Oct 27 12:50 base32 -> ../../bin/gbase32
lrwxr-xr-x 1 me admin 17 Oct 27 12:50 base64 -> ../../bin/gbase64
lrwxr-xr-x 1 me admin 19 Oct 27 12:50 basename -> ../../bin/gbasename
lrwxr-xr-x 1 me admin 14 Oct 27 12:50 cat -> ../../bin/gcat
....
仔细地看透它
`rwxr-xr-x 1 me admin 16 Oct 27 12:50 b2sum -> ../../bin/gb2sum`
它表明b2sum
链接到它的祖父母文件夹,
$ pwd
/usr/local/opt/coreutils/libexec/gnubin
$ cd ../..
$ pwd
/usr/local/opt/coreutils
$ ls | grep gb2sum
# return nothing
实际上,不存在这样的函数gb2sum
,它驻留在
$ which gb2sum
/usr/local/bin/gb2sum
地址没有关系../../bin/gb2sum
,为什么链接显示为lrwxr-xr-x 1 me admin 16 Oct 27 12:50 b2sum -> ../../bin/gb2sum
?
答案1
我相信您忽略了符号链接路径的一个组成部分:
rwxr-xr-x 1 me admin 16 Oct 27 12:50 b2sum -> ../../bin/gb2sum
^----------here
您已经完成了这些../..
部分,但没有执行以下任一操作:
ls -l bin/gb2sum
或者
cd bin
ls -l gb2sum
很可能这种情况/usr/local/bin/gb2sum
本身就是一个符号链接,导致/usr/local/opt/coreutils/bin/gb2sum
.