cam*_*amh 10
GNUfind有-samefile测试。根据手册页:
Run Code Online (Sandbox Code Playgroud)-samefile name File refers to the same inode as name. When -L is in effect, this can include symbolic links.
$ find -L / -samefile /path/to/file
Run Code Online (Sandbox Code Playgroud)
这将找到指向 的所有链接/path/to/file,其中包括硬链接和文件本身。如果您只需要符号链接,则可以单独测试find( test -L)的结果。
您应该阅读它的影响-L是什么,并确保它不会给您的搜索带来任何问题。
注意:虽然文档说它寻找具有相同 inode 编号的文件,但它似乎可以跨文件系统工作。
例如 /home 和 /tmp 是独立的文件系统
$ touch ~/testfile
$ ln -s ~/testfile /tmp/foo
$ ln -s /tmp/foo /tmp/bar
$ mkdir /tmp/x
$ ln -s ~/testfile /tmp/x/baz
$ find -L /tmp -samefile ~/testfile
/tmp/bar
/tmp/foo
/tmp/x/baz
Run Code Online (Sandbox Code Playgroud)
注意这是如何返回 /tmp/bar 的,它是 /tmp/foo 的符号链接,它是 ~/testfile 的符号链接。如果您只想找到指向目标文件的直接符号链接,这将不起作用。