Managing Broken Symlinks
05 Nov 2009
I just added two new functions to my bashrc which make it super-simple to find & remove broken symbolic links on your system.
They’re simple wrappers around the ever-useful “find” utility:
function find_broken_symlinks() { find -x -L "${1-.}" -type l; }
function rm_broken_symlinks() { find -x -L "${1-.}" -type l -exec rm {} +; }
You can call the functions with a specific path:
jerod@mbp:~$ find_broken_symlinks /usr/local/bin
Or you can call them sans argument to search your current working directory:
jerod@mbp:~$ find_broken_symlinks
Enjoy!