How do you find the symbolic links to files.
Jay Windley
jwindley at matt.ksu.ksu.edu
Sun Nov 18 07:30:12 AEST 1990
tcurrey at x102a.ess.harris.com (currey tom 76327) writes:
>> How do you find the # of and locations of all links to a file?
chuck at trantor.harris-atd.com (Chuck Musciano) writes:
> This is an easy one. You cannot.
>
> Well, sort of. You cannot determine which hard links to a file exist
>without examining all the directories in a given file system, looking for
>the specific inode of the file in question. Does anyone know of a tool to
>do this?
SunOS% find /foo -inum <num> -print
where /foo is the mount point of the filesystem and <num> is the inode
number will display the paths of all hard links to an inode.
> Symbolic links are tougher. Since sym-links can span file systems and
>NFS, you are not guaranteed to ever find all of them, only the ones in files
>systems you have access to. You need to use find to find all symbolic links,
>and then examine the link to see if it points to the file in question. This
>can be tough, since some links are quite circuitous and not at all obvious.
If you really want to, from a csh executing with root permissions enter the
following command:
SunOS# find / -type l -exec file {} \; | egrep <fname> > find.out
where <fname> is any hard link to the file in question. This will bog your
machine significantly, so use at your own risk. Upon completion, find.out
will contain a list of symbolic links to the file.
> Easiest way: remove the file in question. Wait for the phone to ring.
Well, I suppose this would work too, unless the file in question belongs
to your boss :-).
--
Jay Windley - CIS Dept. - Kansas State University
NET: jwindley at matt.ksu.ksu.edu VOICE: (913) 532-5968 FAX: (913) 532-6722
USnail: 323 Seaton Hall, Kansas State Univ., Manhattan, KS 66506
Obligatory quote: "" -- /dev/null
More information about the Comp.unix.internals
mailing list