Broken links

Richard Lightman richard at
Sun Aug 18 01:15:12 PDT 2002

* Timothy Bauscher <timothy at> [2002-08-18 07:45]:
> On Sat, Aug 17, 2002 at 10:13:15PM -0400, James Drabb wrote:
> > Are there any tools out there to scan a directory for broken links?
> > I know I have some broken links under /usr and want to clean them up.
> (just watch. someone else will make a one liner. such is
> my life...)
And make it search the whole tree.
And handle nasty file names with spaces, ':' and 'broken symbolic link'

find /usr -type l -print0 | xargs -0i bash -c "[ -e '{}' ]||echo '{}'"

That is a bit slow, because it invokes bash for every argument.
If you can live with two lines this is fast:

find /usr -type l -print0 | xargs -0 bash -c \
 'while [ $# -gt 0 ];do [ -e "$1" ]||echo "$1";shift;done' find_broken

Unsubscribe: send email to listar at
and put 'unsubscribe blfs-support' in the subject header of the message

More information about the blfs-support mailing list