在我的 Linux 机器上:
$ pwd
/usr/share/file/sharedspace
$ ls -l
lrwxrwxrwx. 1 system system 18 Aug 26 18:07 file.txt -> ../../original
$ rm file.txt
如何使用绝对路径名修改此路径链接?
答案1
您正在寻找带有解析完整路径的标志readlink
的命令:-f
$ pwd
/usr/share/file/sharedspace
$ ls -l
total 0
lrwxrwxrwx 1 root root 14 Jul 25 12:25 file.txt -> ../../original
$ readlink -f file.txt
/usr/share/original
从man readlink
:
-f, --canonicalize
canonicalize by following every symlink in every component of
the given name recursively; all but the last component must ex‐
ist