On 07/05/07, John Ferlito <[EMAIL PROTECTED]> wrote:

On Mon, May 07, 2007 at 11:15:51AM +1000, Alan L Tyree wrote:
> Is there some easy way to find all the symbolic links that point to a
> given target?
>

No real easy way since for symbolic links there is no reverse lookup
table in the filesystem. So you need to trawl the whole filesystem
looking from them.

Something like


find / -lname 'regex of original linked file name' -exec ls -l {} \;


The tricky part here is that since links can be relative thay could
look like any of
../file
/moo/file
../../l/../../file

etc so you need to cookup an appropriate regex. For all of the above
file
is probably the simplest


What about "find -L -samefile give-target"?

e.g.

$ touch target
$ ln -s target link-to-target
$ ls -l
total 0
lrwxrwxrwx ... link-to-target -> target
-rw-r--r-- ... target
$ find -L -samefile target
./target
./link-to-target

--Amos
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to