Ubuntu: How to count the number of Files in a Directory via the Terminal CodeUnit 18 JUL 2011

In order to count the number of files in a directory or folder in Ubuntu via the terminal, it is a simple matter of using the ls listing command with a numeric 1 switch and then piping its result to the line count function wc. In practice, this would retrieve the number of files in the current working directory (non recursive):

ls -1 | wc -l

If you say need a recursive count of all the files under the current working directory, simply run:

find . -type f | wc -l


Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.