I want a command that counts files in a tree like du does sizes but without having to pipe find through wc which is crazy for hundred thousand files. Can't they just directly access inodes for high speed counting?
There really isn't any way around this. The first pass over your data is going to be slow while the inode data is examined, but it will be cached for the next pass. If you do this before that data gets removed from the cache it will be much faster. imac:~ $ time find . | wc -l 419191 real 0m37.865s user 0m0.385s sys 0m2.611s imac:~ $ time find . | wc -l 419195 real 0m10.503s user 0m0.330s sys 0m1.430s
What do you do when find cannot handle the sheer number of files, argument too long from the linux hardcoded MAX_ARG_PAGES
We need a dedicated utility that counts inodes.