#!/bin/sh
# find_broken_symlinks.sh
# 2015-07-06
# by Gernot Walzl
DIR="$1"
if [ -z "$DIR" ]; then
DIR="."
fi
find "$DIR" \
\( -path '/dev' -o -path '/proc' -o -path '/run' \) -prune -o \
-type l -print0 \
| xargs -0 --no-run-if-empty file \
| grep 'broken symbolic link' \
| sed 's/:\s\+/: /'