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

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

1 Answer 1

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
2
  • 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, 2013 at 11:51
  • @Sirch you are of course correct. Fixed.
    – ptman
    May 24, 2013 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .