Count number of files in directory using bash

To count the number of files in a directory using a bash shell, one can use a variation of:
ls -1 | wc -l
such as
ls -1 *.tsv | wc -l
Note that the option after ls is the number "1" and not the letter "l". This will take the output of ls and pipe it to wordcount with the newline option, where it counts the number of newline characters.


Popular Posts