Tips 'n' Tricks » GNU/Linux Command Line Tips » Counting files in a directory
Counting files in a directory
To count the number of files in a directory use the following command:
ls -1 | wc -l
The option to the ls command is a 1 (one), the option to the wc coomand is a lowercase L.
The ls command lists the files in one column which is piped to the wc command which counts the lines
Back to GNU/Linux Command Line Tips