Code:
ls -lL /usr/bin 2>/dev/null | grep "\?"
Works for me.
Code:
-L, --dereference
when showing file information for a symbolic link, show informa‐
tion for the file the link references rather than for the link
itself
EDIT: If you want to generate a nicely formatted list (pipeable into rm), try this:
Code:
ls -lL /usr/bin 2>/dev/null | grep "\?" | sed "s/l[\?[:space:]*]*//g" | tr '\n' ' ' > ~/brokenlinks.txt
Instead of redirecting the output to a file, you can use backticks with rm:
Code:
sudo rm `ls -lL /usr/bin 2>/dev/null | grep "\?" | sed "s/l[\?[:space:]*]*//g" | tr '\n' ' '`
Make sure that the command works correctly for you before you try this though.
Bookmarks