我想删除圆形符号链接。 这里的问题是如何正确解析find -follow命令生成的循环链接?
find /home/ -follow -printf "" find: File system loop detected; `/home/domain_names_new/biz/2015-04-09_03_44_31/2015-04-09_03_44_31' is part of the same file system loop as `/home/domain_names_new/biz/2015-04-09_03_44_31'. find: File system loop detected; `/home/domain_names_new/biz/2015-04-09_03_44_31/2015-04-13_03_44_03/2015-04-09_03_44_31' is part of the same file system loop as `/home/domain_names_new/biz/2015-04-09_03_44_31'. find: File system loop detected; `/home/domain_names_new/biz/2015-04-09_03_44_31/2015-04-13_03_44_03/2015-04-13_03_44_03' is part of the same file system loop as `/home/domain_names_new/biz/2015-04-09_03_44_31/2015-04-13_03_44_03'.
答案 0 :(得分:2)
这是我用来使用find follow的输出删除子链接:
find /home/ -type l -follow -printf "" 2>&1 | sed -e "s/.*detected; \`\(.*\)' is part.*/\1/" | xargs rm
首先将错误流重定向到stdout:
2>&1
在“detected;”和“'is part”之间提取文件名
sed -e "s/.*detected; \`\(.*\)' is part.*/\1/" :
删除相应的文件
xargs rm
答案 1 :(得分:0)
似乎/ home / domain_names_new / biz / 2015-04-09_03_44_31 / 2015-04-09_03_44_31指向其父文件夹/ home / domain_names_new / biz / 2015-04-09_03_44_31。您可以使用
进行检查ls -l /home/domain_names_new/biz/2015-04-09_03_44_31/2015-04-09_03_44_31
注意:其他两个错误也有类似的问题;每次链接指向其父文件夹。
因此您需要删除此链接或进行更正。没有"魔法"解;只有你知道链接指向的位置,系统才能知道这一点。