I run find
and iterate through the results with [ \( -L $F \) ]
to collect certain symbolic links.
I am wondering if there is an easy way to determine if the link is broken (points to a non-existent file) in this scenario.
Here is my code:
FILES=`find /target/ | grep -v '\.disabled$' | sort`
for F in $FILES; do
if [ -L $F ]; then
DO THINGS
fi
done
find
but in other scenarios (such as globs) should be combined with -h to handle this case, for instance[ -h "$F" -a ! -e "$F" ]
. – Englishism