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

Re: A direct way to find hard links?



Adam Funk wrote:
> When I see in a listing that a file has one or more other hard links, for
> example:
[snip]
> is there any direct way to find the other /path/to/files that point to the
> same inodes?

Something like in bash:

for (( i=2 ; $i < 10 ; i = $i +1 )) ; do find . -links $i -and -type f
; done

should do it. Change the path in find to find links elsewhere. Change 10
to the biggest number you can guess is there. The above finds regular
files only. If you want to find directories too, then mind that every
directory is hardlinked at least twice, as . also counts.

I assume my bash is dreadful, so if you have a prettier solution just
tell me.

Andro

-- 
Andrey Andreev
University of Helsinki
Dept. of Computer Science



Reply to: