Reputation: 41
I was thinking that it would be the sum of the link counts within the directories?
Upvotes: 3
Views: 3802
Reputation: 44250
The link count is not about directories, it is about inodes. The link count is essentially a reference count.
Upvotes: 5
Reputation: 27228
Do you just want to sum up the link count of all the subdirectories?
What's exactly the purpose, may I ask?
You could do something similar to Unix find average file size:
find ./ -type d -ls | awk '{sum += $4;} END {print sum;}'
You could even find the average link count, whilst at it:
find ./ -type d -ls | awk '{sum += $4; n++;} END {print sum/n;}'
Upvotes: 0
Reputation: 15530
Linux find utility has an option -type d to filter certain type (directory, file, symbolic link, socket or other) so it should help alongside with wc -l to count number of STDOUT lines:
find ./ -type d | wc -l
If you need to limit number of nested directories use -maxdepth parameter:
find ./ -type d -maxdepth 2 | wc -l
Upvotes: 0