Count Lines in File in Linux

Last updated on Dec 29, 2019 in Linux

Counting lines of a text file can be done with a one simple Linux command wc, which stands for word count, but with parameter -l it counts also lines. Note, this tutorial only applies to text files, not binary files.

Let’s assume that your file is named myfile.txt. In terminal, type:

$ wc -l myfile.txt

The output is the number of lines in the file.