我在不同的路径上创建了许多文件或目录的符号链接。我想要整个已创建符号链接路径(位置)的列表。
示例:
我在许多目录中为~/Pictures目录创建了符号链接。如何列出所有指向该~/Pictures目录的符号链接?
这可能吗?如果是,那么怎么做?
示例:
我在许多目录中为~/Pictures目录创建了符号链接。如何列出所有指向该~/Pictures目录的符号链接?
这可能吗?如果是,那么怎么做?
find -L /dir/to/start -xtype l -samefile ~/Pictures
find -L /dir/to/start -xtype l -samefile ~/Pictures 2>/dev/null
-lname
。find / -lname /path/to/original/dir
man find
中找到的内容:-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The
metacharacters do not treat `/' or `.' specially. If the -L option or the
-follow option is in effect, this test returns false unless the symbolic link
is broken.
../dir
,那么它将无法找到绝对路径 /path/to/original/dir
。您可以使用模式并排除错误的匹配项 -lname \*dir
。 - Jason Sls -i ~/
277566 Pictures
find . -follow -inum 277566
(查找具有相同inode号的目录)
它将显示所有符号链接的路径。
https://unix.stackexchange.com/questions/21984/list-symlinks-in-current-directory