word count wc

Count Number of Lines in a File

Back to basics with this one, the linux wc command (word count) can be used to count lines, words and bytes in a file and it does it lightning fast. Many times it’s also combined with other commands to get the results you want.

Number of lines in a file

cat file.csv | wc -l

 

Number of words in a file

This isn’t a very useful command as is, but it will return a count of all words, a word is any contiguous non whitespace character(s) separated by a whitespace character.

wc -w file.txt

 

Number of characters in a file

wc -m file.txt

Leave a Reply

Your email address will not be published. Required fields are marked *