我正在使用HP-UX系统,我想查找是否有任何循环符号链接。
到目前为止,我正在使用这个命令:
ls -lrt `find ./ -follow -type l`
但是只能在当前目录下执行ls -lrt。
我应该使用什么命令来查找系统中的所有循环符号链接?
GNU find的手册页说,在这些情况下,所有POSIX发现应该检测文件系统循环并发出错误消息,并且我testing了
find . -follow -printf ""
在GNU find上,它能find./a -> ./b和./b -> ./a格式的循环。打印错误
find: `./a': Too many levels of symbolic links find: `./b': Too many levels of symbolic links
(这也适用于a->b->c->a )
同样, ./foo/x -> .. / ./foo/a -> ./bar ./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 `.'.
如果你想对输出进行一些操作而不是读取它,你需要将它从stderrredirect到stdout,并将其传递给一些可以parsing出错信息的脚本。