Computergeekery Tips trivial shennanigans

HOWTO Find broken symbolic links – Gentoo Linux Wiki

HOWTO Find broken links – Gentoo Linux Wiki

I was trying to find some broken links. however, although using
find . -type l

shows all links, it does nto use the cool flashing RED that BASH can do to shwo a broken links. So doing a quick Google turned me to this Gentoo howto: Nice n easy!
find . -type l | (while read FN ; do test -e "$FN" || ls -ld "$FN"; done)

14 replies on “HOWTO Find broken symbolic links – Gentoo Linux Wiki”

To also show what the broken links used to point to:
find -L Documents -type l -ls
– or –
find -L Documents -type l -exec ls -l “{}” \;
– or –
find -L Documents -type l -exec ls -l –color “{}” \; ## colorized

er, better off without the ‘ because your blog seems to turn it into the UTF-8 quotes:

find . -type l ! -execdir test -e {} \; -print

Another one assuming you are supposed to be able to read all files.

This will match any link to a non-readable file.

find . -type l ! -readable

Another one assuming you never have symlimks to symlinks:

find . -type l -xtype l

Hi Bill, your example will delete all symbolic links. Plus xargs is far neater!
The original example is to use ‘ls -l’ so that Bash will show broken symlinks in flashing red (if setup that way!).

Comments are closed.