Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

Managing Broken Symlinks

Posted: November 5th, 2009 | Author: Jerod | Filed under: Bash | Tags: , , | Comments

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!


blog comments powered by Disqus