如何停止递归符号链接

Ken*_*cks 5 symlink ln

我有一个以下文件夹:

  • 文件夹A
  • 文件夹 B(这是文件夹 A 的符号链接)

问题是,当我访问文件夹 B 时,我可以无限深入(即文件夹 A > 文件夹 B > 文件夹 B > 文件夹 B),因为文件夹 B 位于文件夹 A 内。

通过文件夹 A 访问文件夹 B 后有什么方法可以忽略文件夹 B 吗?

小智 4

find命令检测符号链接循环并将打印警告消息,而不是重复遍历它们。例如,使用-L跟随符号链接的选项可能会打印此警告:

$ find -L /some/path

find: File system loop detected; `/some/path/link' is part of the same file system loop as `/some/path'.
Run Code Online (Sandbox Code Playgroud)

从手册页:

          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.
Run Code Online (Sandbox Code Playgroud)