0

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

greg0ire
  • 3,005

1 Answers1

5

As found on 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
ptman
  • 424
  • 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