Does find -links count the hard links or symbolic links

findlinks

Does find -links count the hard links or symbolic links ?

find -links 2

Best Answer

Hard links. That's the only type for which its even possible to count. Pretty much every find option is something fairly trivially obtained for each file; the hard link count comes from stat (and is also displayed by ls, by the way).

(To count symlinks, you'd have to examine every symlink and check where it points. But that's not even possible—symlinks can cross filesystems, and all of them may not be mounted. Or could be mounted in different locations, which could leave the symlinks pointing the different things. You could count only the ones in the files find searches through, but that's very non-trivial for a file match flag.)

Related Question