On Fri, 19 Sep 2003 15:25:42 -0500
"Rigler, Steve" <[EMAIL PROTECTED]> wrote:

> To find symbolic links recursively you could do:
> 
> find . -type l -print
> 
> I don't know of a way to find hardlinks.
> 

Hard links are indistinguishable from the original file.

Whereas the softlink search you showed won't return the original file 
the following search will return the hardlinks _and_ the original file:

find -type f -links +1

Unfortunately this won't group hardlinks associated with each
file together, for that you need something like:

find -xdev -type f -links +1 -printf '%i %p\n' | sort -n 

Which prepends the inode (unique file number) in front of each hardlink
so that they can be properly grouped by the sort command.  The -xdev
option is needed so that only one filesystem is scanned because inode
numbers are not necessarily unique across filesystems.

To combine the hard & soft link search into one:

find -type l -o -type f -links +1

Cheers,
Sean


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to