[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Finding hard links



On Tuesday 17 October 2006 22:45, T wrote:
> Hi
>
> How can I find hard linked files?

Hi,
using for example:
[ "`stat -c %h filename`" -gt 1 ]  && echo hard linked

> Is it possible to find the hard links of the same file? Ie, group the
> above finding into same file groups?

AFAIK it's not possible using general purpose tool.
Maybe some filesystem offer a specific interface to get the file name(s) given 
the inode number (as ncheck on aix), but I don't have made any deep 
investigation. 

Usually general purpose tools (tar, rsync) use an hash table and repeat the 
check for every file.

You could make your own simple map using this expensive command
find /somepath -xdev -type f -printf '%n %i% %p\n' | grep -v '^1 ' | sort -k2

Regards,
Daniele



Reply to: