2015-08-28 67 views
0

我想删除圆形符号链接。 这里的问题是我如何正确解析出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

看看每个文件指向的位置:使用'ls -l' –

回答

0

好像/家庭/ domain_names_new /商业/ 2015-04-09_03_44_31/2015-04-09_03_44_31指向它的父文件夹的/ home/domain_names_new /商业/ 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 

注意:另外两个错误有类似的问题;每次都有一个指向其父文件夹的链接。

因此您需要移除该链接或更正此链接。没有“魔术”解决方案;只有你知道链接应该指向哪里,系统无法知道这一点。

+0

@ user121196:如果我的答案对您有帮助,请考虑接受它。 –

1

这是我会用删除链接儿童使用find后续的输出:

find /home/ -type l -follow -printf "" 2>&1 | sed -e "s/.*detected; \`\(.*\)' is part.*/\1/" | xargs rm 

第一个重定向错误流到stdout:

2>&1 

提取之间的“文件名检测到;“和”是部分“

sed -e "s/.*detected; \`\(.*\)' is part.*/\1/" : 

删除相应文件

xargs rm