Monday, December 6, 2010

Howto - Find broken symbolic links

2 cool ways to find broken symbolic links on your system:
for i in `find /`; do if (test -h $i); then file $i|grep broken; fi; done

./bar_link: broken symbolic link to `/etc/foo'

Any Shell:
find / -type l ! -exec test -r {} \; -print


When measuring the results with "time" command - the 2nd command wins, so if performance is critical in your case, use the 2nd one :)