symlink - 如何停止递归符号链接(symbolic link)

标签 symlink ln

我有以下文件夹:

  • 文件夹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/

相关文章:

linux - 将链接复制到多个子文件夹

laravel - : failed to create symbolic link: Protocol error (in Vagrant)

linux - "ln -sf"不覆盖目录的符号链接(symbolic link)

linux - 'ln' 或 'ln -s' 的用法或应用场景是什么?

macos - 即使使用 sudo 也无法在/usr/bin 内创建符号链接(symbolic link)

linux - 如何在 Linux 中的 makefile 中创建指向目录的链接?

symlink - rsync 使用 --delete 但不想删除目的地的符号链接(symbolic link)

windows - Powershell 删除符号链接(symbolic link) Windows

linux - 两个符号链接(symbolic link)之间的符号链接(symbolic link)

ansible - 设置符号链接(symbolic link)错误 - Ansible