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

find -links 2

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.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.