Recursively finding symbolic links

Post date: Jan 30, 2010 6:58:29 PM

Linux Command Prompt

Have you ever needed to find all the symbolic links you have created to a certain directory? I recently wanted to move some partitions around on my drives and needed to see where I had mounted and linked to them before I moved them. Here is a quick way to search for all the links.

find command

sudo find / -mount -type l -print | sudo xargs ls -ld | awk '{print $10}' | grep /mnt/f11

It uses the find command and goes through the entire file system looking for the sym links then listing only the ones that point to the directory I am looking for (specified as the last parameter. Note that the '-mount' option stays on the current file system.

Take a look at this good description & usage of find.