Counting files (list and word count, ls & wc)
First published April 29, 2020 • Last modified on July 18, 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