Quantcast
Channel: How can I find broken symlinks - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 14

Answer by andy for How can I find broken symlinks

$
0
0

If you need a different behavior whether the link is broken or cyclic you can also use %Y with find:

$ touch a
$ ln -s a b  # link to existing target
$ ln -s c d  # link to non-existing target
$ ln -s e e  # link to itself
$ find . -type l -exec test ! -e {} \; -printf '%Y %p\n' \
   | while read type link; do
         case "$type" in
         N) echo "do something with broken link $link" ;;
         L) echo "do something with cyclic link $link" ;;
         esac
      done
do something with broken link ./d
do something with cyclic link ./e

This example is copied from this post (site deleted).

Reference


Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>