Symlink
gnubin 中的錯誤連結但仍然有效
我檢查目錄
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
?
我相信您忽略了符號連結路徑的一個組成部分:
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
.