finding the missing links

Erik Baalbergen erikb at cs.vu.nl
Tue May 30 19:22:12 AEST 1989


In article <207 at flattop.UUCP> rcm at flattop.UUCP (Ron McDowell) writes:
>At the risk of starting another 'RTFM' war, I'd like the answer to a simple
>question:  
>
>$ echo "hello world" > $HOME/xxx ; ln xxx /tmp/yyy ; ln xxx /usr/tmp/zzz
>
>I do a 'ls -l /tmp' and see that yyy has 3 links.  How can I find the other
>two files?

Find out /tmp/yyy's inode number, <inum>, by typing 'ls -i /tmp/yyy'.  
Then find all files with this particular <inum> as inode number:
	find / -inum <inum> -print
This command will print at least the three file names you mentioned. 
If multiple file systems are mounted, there is a chance that more file names
are printed since the inode number is unique only within a single file system.
You can apply further heuristics, like
	find / -inum <inum> -links 3 -user <your user name> -print
or even
	find / -inum <inum> -exec cmp '{}' /tmp/yyy ';' -print
See the 'find' manual page for details.

Unfortunately, it is not possible to use the device number to 'find' files.
The combination of device and inode number uniquely determines a file within
a (non-network-file-system) UNIX system.  Perhaps we should equip any future
'find' program with the "-dnum <dnum>" primary expression.
If you have a 'stat' command available, you can check the device numbers by 
hand.

Erik Baalbergen
-- 
Erik H. Baalbergen				    <erikb at cs.vu.nl>
Vrije Universiteit / Dept. of Maths. & Comp. Sc.
De Boelelaan 1081
1081 HV Amsterdam / The Netherlands		tel. +31 20 548 8080



More information about the Comp.unix.questions mailing list