How do you find the symbolic links to files.

Root Boy Jim rbj at uunet.UU.NET
Tue Dec 11 11:46:52 AEST 1990


In article <BZS.90Nov27120756 at world.std.com> bzs at world.std.com (Barry Shein) writes:
>From: mchinni at pica.army.mil (Michael J. Chinni, SMCAR-CCS-E)
>>If so, how would you find all symbolic links to the file ?

The hard way. By looking thru the entire filesystem, examining
every file, and determining whether it points to the target.

>In general, it's very difficult. Consider that valid symlinks can
>point across NFS mounts. 

Hmmm, I hadn't thought of that.
I suppose it all depends on what stat returns for st_dev and st_ino.

>	% find /mount-point -type l -a -exec testinode '{}' #inum ';'

Gee, Barry, using -exec is so passe :-) XARGS is the way to go.

Your program testinode should accept multiple arguments. The
first arg is special and contains tha name of the target file.
If the st_dev and st_ino match, print the sucker.

>        -Barry Shein
>
>Software Tool & Die    | {xylogics,uunet}!world!bzs | bzs at world.std.com
>Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD
-- 

	Root Boy Jim Cottrell <rbj at uunet.uu.net>
	Close the gap of the dark year in between



More information about the Comp.unix.internals mailing list