3 ms·
> Another trick is based on the fact that the link count of a directory is 2 + the number of subdirectories. For anyone who doesn't know why this is, it's beca
by olddustytrail 2y ago
> Another trick is based on the fact that the link count of a directory is 2 + the number of subdirectories.
For anyone who doesn't know why this is, it's because when you create a directory it has 2 hard links to it which are
dirname
dirname/.
When you add a new subdirectory it adds one more link which is
dirname/subdir/..
So each subdirectory adds one more to the original 2.