use find to find symlinks

use find to find symlinks

Post by Edwar » Fri, 11 Jan 2002 01:36:27



Can I use the find command to search for all files that link to a particular
directory?

My account doesn't have permission to list the contents of a directory, but
I might have execute permissions on files within it to be accessed via sym
links in directories I can access.   (I don't know if this is possible -
just guessing really)

Thanks,

Edward

 
 
 

use find to find symlinks

Post by Barry Margoli » Fri, 11 Jan 2002 04:13:53




>Can I use the find command to search for all files that link to a particular
>directory?

>My account doesn't have permission to list the contents of a directory, but
>I might have execute permissions on files within it to be accessed via sym
>links in directories I can access.   (I don't know if this is possible -
>just guessing really)

I don't think find has an option to match the target of a link.  You can
use find to find all symlinks, and then something else to compare the
target:

find / -type l -ls | grep ' -> /path/to/target/directory/'

This will only find links whose targets use an absolute pathname to access
the directory.  Symlink targets can also be relative pathnames, which are
interpreted relative to the directory containing the link.  It would be
possible to write a script that merges the directory portion of the symlink
path with the target, but it will be much more complex than the above.  And
if a symlink points to another symlink, it gets much harder still.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

use find to find symlinks

Post by Barry Margoli » Wed, 16 Jan 2002 02:54:51






>#  >Can I use the find command to search for all files that link to a particular
>#  >directory?
>#  >
>#  >My account doesn't have permission to list the contents of a directory, but
>#  >I might have execute permissions on files within it to be accessed via sym
>#  >links in directories I can access.   (I don't know if this is possible -
>#  >just guessing really)
>#  
>#   I don't think find has an option to match the target of a link.

>What about the "-follow" option?

That causes the attribute tests (e.g. -mtime) to look at the target file
instead of the link, but it still doesn't provide a way to find files whose
target matches /path/to/some/directory/*.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.