Counting files (list and word count, ls & wc)
Last modified on July 24, 2026 • 1 min read • 100 wordsHow do you count the number of files in a directory?
ls | wcls lists your files one per row and wc returns three numbers: lines, words and bytes. In the file counting example, lines and words are the same and equal the number of files in the directory. To count all files recursively in the directory tree “backcheck”:find backcheck/ -type f | wc -l