Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I get the number of inodes used by files in a given directory tree? Important: including hidden directories under it, like .git

share|improve this question

migrated from serverfault.com May 24 '13 at 15:24

This question came from our site for professional system and network administrators.

    
@ptman: thanks, but my problem is mostly about the "Important" warning... –  greg0ire May 24 '13 at 10:11
    
And why would find . exclude those? –  ptman May 24 '13 at 10:13
    
Woops, turns out it does not, you're right –  greg0ire May 24 '13 at 10:18
add comment

1 Answer 1

up vote 4 down vote accepted

As found on http://unix.stackexchange.com/questions/4105/how-do-i-count-all-the-files-recursively-through-directories

find . -printf '%i\n' | sort -u | wc -l

Or if you don't have GNU find and need a portable version:

find . -exec ls -id '{}' \; | awk '{print $1}' | sort -u | wc -l
share|improve this answer
    
solaris wont like that because of the multiple spaces before the inode number, you also need to uniquely sort before counting lines, as im sure you know. find . -exec ls -id {} \; |awk '{print $1}' | sort -u | wc -l –  Sirch May 24 '13 at 11:51
    
@Sirch you are of course correct. Fixed. –  ptman May 24 '13 at 13:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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