Menu

Count lines in a file

wc (short for word count) is a command in Linux that displays a count of lines (newline characters, to be precise), words, and bytes for each file you specify. The program prints these three numbers for each file you specify. For example, to find out how many lines, words and bytes random-text.txt has, we can use the following command:

In the picture above you can see that the random-text.txt file contains 12 lines, 12 words, and its size is 39 bytes.

You can specify more than one file:

 Use the -l option to print only the line count, -w to print only the word count, and -c to print only the bytes count. 

Leave a Reply

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