Count the Number of Files in a Directory
ls -l | wc -l
ls
: list directory contents-l
: list in long format
wc
: word, line, character, and byte count-l
: the number of lines is written to the standard output
This command counts the number of listed lines. I find this most useful when I want to quickly see how many logs or records have been generated by a process.