[KLUG Members] Testing for files with symbolic links

Peter Buxton members@kalamazoolinux.org
Tue, 20 Nov 2001 02:49:26 -0500


On Thu, Nov 15, 2001 at 11:10:22PM -0500, Patrick Mc Govern was only 
   escaped alone to tell thee:

> I want to test for files with symbolic links in a shell script.  I tried
> find, stat, symlinks with no luck.  I tried the following link test: [ -L
> $HOME/linked_dir/linked_file ]  but it returns "1" when I know this
> directory/file is symbolically linked to another directory.  The above
> test should work.  Is there must be a simple way to test links?  Pat 

Is that, 'test for file with symbolic links [pointing to them]'?

Hard links are always visible. A simple 'ls -l' will show you that your file
has two links pointing to it.

But a symbolic link is something else. Technically, a hard link is just
another directory link in the file's inode. (Very simplified.) But a
symbolic link is just a bit of text in a file with a /path/filename in it.
To find out if a file has a symbolic link pointing to it you would need to
search the entire hard drive for symbolic links and test each one to see if
it points to your file.

-- 
i'm determined to stand, whether god
will deliver me or not. -- bob dylan