如何找到圆形符号链接?

Vla*_*mir 13 unix find symbolic-link hp-ux

我在 HP-UX 系统上工作,我想查找是否有任何循环符号链接。

到目前为止,我正在使用以下命令:

ls -lrt  `find ./ -follow -type l`
Run Code Online (Sandbox Code Playgroud)

但结果只是在当前目录上执行 ls -lrt 。

我应该使用什么命令来查找系统中的所有循环符号链接?

Der*_*rfK 20

GNU find 的联机帮助页说所有 POSIX 发现都应该检测文件系统循环并在这些情况下发出错误消息,我已经测试过

find . -follow -printf ""
Run Code Online (Sandbox Code Playgroud)

在 GNU find 上,它能够找到表单的循环./a -> ./b./b -> ./a打印错误

find: `./a': Too many levels of symbolic links
find: `./b': Too many levels of symbolic links
Run Code Online (Sandbox Code Playgroud)

(这也适用a->b->c->a

同样,表单./foo/x -> .../foo/a -> ./bar+ 的循环./bar/b -> ./foo打印错误

find: File system loop detected; `./foo/a/b' is part of the same file system loop as `./foo'.
find: File system loop detected; `./bar/b/a' is part of the same file system loop as `./bar'.
find: File system loop detected; `./foo/x' is part of the same file system loop as `.'.
Run Code Online (Sandbox Code Playgroud)

如果您想对输出执行某些操作而不是读取它,则需要将其从 stderr 重定向到 stdout 并将其通过管道传输到某个可以解析错误消息的脚本。