我运行 find
并使用 [\( -L $F\) ]
遍历结果以收集某些符号链接(symbolic link)。
我想知道在这种情况下是否有一种简单的方法来确定链接是否已损坏(指向不存在的文件)。
这是我的代码:
FILES=`find /target/ | grep -v '\.disabled$' | sort`
for F in $FILES; do
if [ -L $F ]; then
DO THINGS
fi
done
最佳答案
# test if symlink is broken (by seeing if it links to an existing file)
if [ ! -e "$F" ] ; then
# code if the symlink is broken
fi
关于bash - 如何检测 Bash 中的符号链接(symbolic link)是否损坏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8049132/