[CLUE-Tech] Finding all hard links to a file

Chris Greene r0x0rman at yahoo.com
Sat May 15 16:31:37 MDT 2004


You should be able to use find for this.

Example: find /home -inum 32092 -print

I had a file named 'word' in my home directory.  I created a hard link 
with "ln word yo".  When I ran "ls -li" I received:

 32092 -rw-rw-r--  2 chris chris 2318 May 14 11:16 word
 32092 -rw-rw-r--  2 chris chris 2318 May 14 11:16 yo

You can see they both have the same inode #.  Running "find /home -inum 
32092 -print" resulted in:
/home/chris/word
/home/chris/yo



Keith Hellman wrote:

>On Sat, May 15, 2004 at 02:35:11PM -0400, Angelo Bertolli wrote:
>  
>
>>would seem like a relatively simple thing:  just a program which when
>>given a file name,  reads it's inode number, and then traverses the
>>inode table looking for matches and spitting out their locations.
>>However, without using find -inum,  I can't think of any quicker way.
>>    
>>
>
>I think your right, I would use this in my .bashrc 
>  function findinum() { find -inum $(ls -i "${1}"|awk '{print $2;}'); }
>or set it up as a shell script if you need other scripts to invoke it.
>
>  
>



More information about the clue-tech mailing list