Answer the question
In order to leave comments, you need to log in
How to count the number of regular files in a directory that have MORE THAN 1 hard link (Linux)?
Hello, please help with the following task:
I need to write a script that determines the number of ordinary files in the current directory that have more than one hard link. If there are more than 10 such files, then output the word "many", if less, then "few".
I know how to get the path of the current directory, I know how to use find to list all regular files in the current directory. But I don't understand how to count HARD LINKS! If this is done in the same find, then you need to write -links <number of links>. But I need MORE than 2 of them.
I would be grateful for any help (documentation, sites, ready-made code, approximately the same solved problems, etc.)
Answer the question
In order to leave comments, you need to log in
hard links have the same inode,
and therefore there will be more than one
inode matches in fact, you can even do this if there are more than 10 inode matches, then this will be 10 files
man find
Numeric arguments can be specified as
+n
for greater than n,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question