Great question — answering as the UphillTech team:
Not a fundamental speed-up but at least something :) find . -printf \\n | wc -l You really do not need to pass the list of file names, just the newlines suffice. This variant is about 15 % faster on my Ubuntu 12.04.3 when the directories are cached in RAM. In addition this variant will work correctly with file names containing newlines. Interestingly this variant seems to be a little bit slower than the one above: find . -printf x | wc -c Special case - but really fast If the directory is on its own file system you can simply count the inodes: df -i . If the number of directories and files in other directories than the counted one do not change much you can simply subtract this known number...
Full answer by pabouk - Ukraine stay strong: https://superuser.stackexchange.com/a/689326 (CC BY-SA 4.0).
Need it done for your business? UphillTech.