How to count number of lines in a text file using Linux shell

Sometimes you need an easy way to count number of lines in a text file.
For example, how many lines in a .csv file.

Easy:
wc -l somefilename.csv

You can also count number of characters in a file using “wc”:
wc -m somefilename.txt

Or number of words:
wc -w somefilename.txt

Explore the possiblities of “wc”:

# wc --help
Usage: wc [OPTION]... [FILE]...
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -,
read standard input.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
-L, --max-line-length print the length of the longest line
-w, --words print the word counts
--help display this help and exit
--version output version information and exit

Report bugs to .

Tagged with 
About sepedatua
I am nothing special, of this I am sure. I am a common man with common thoughts and I’ve led a common life. There are no monuments dedicated to me and my name will soon be forgotten, but I’ve loved another with all my heart and soul, and to me, this has always been enough.

This site uses Akismet to reduce spam. Learn how your comment data is processed.