Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Search Forums:




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
    #2  
Old 03-25-2001
mib mib is offline
Registered User
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
Thanks: 0
Thanked 3 Times in 2 Posts
find &ltdir&gt ! -type d -links +1 -ls|sort -n

this will print all hardlinks in specified directory, sorted by files i-node.

the ! -type d is to avoid directories.
The -links +1 will find all files that have MORE than 1 link. Hardlinked files have a link count of at least two.
The -ls is used to view the inode number after find has found the file.
- The sort -n will sort the list by inode number showing you which files are hardlinked together.

This will only work if your search includes the directories that contain all of the hardlinked files.


here is anotherway

f=`ls -i $srch_arg |awk '{print $1}'`
find / -inum $f

this will search all system and print any files that is hardlinked with $srch_arg



[Edited by mib on 03-25-2001 at 06:05 AM]