我有以下文件夹:
- 文件夹A
- 文件夹 B(这是指向文件夹 A 的符号链接(symbolic link))
问题是,当我访问文件夹 B 时,我可以无限深入(即文件夹 A > 文件夹 B > 文件夹 B > 文件夹 B),因为文件夹 B 在文件夹 A 中。
有没有办法在通过文件夹 A 访问文件夹 B 后忽略它?
非常感谢!
最佳答案
find
命令检测符号链接(symbolic link)循环并将打印警告消息而不是重复遍历它们。例如,使用 -L
选项跟随符号链接(symbolic link)可能会打印此警告:
$ find -L /some/path
find: File system loop detected; `/some/path/link' is part of the same file system loop as `/some/path'.
来自手册页:
The find utility shall detect infinite loops; that is,
entering a previously visited directory that is an ancestor of
the last file encountered. When it detects an infinite loop,
find shall write a diagnostic message to standard error and
shall either recover its position in the hierarchy or
terminate.
关于symlink - 如何停止递归符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56941346/