How To Show How Many Lines In A File In Linux

When you are dealing with text files in Linux with a command line, it is often very useful to know how many lines are in a file. This article will describe the Bash command on how to show the number of lines in a text file in Linux.

How To Show How Many Lines In File In Linux

The command to show many lines in a file in command line in Linux is very simple. Basically, all you do is do
wc -l filename

filename is the name of the file you want to know how many lines there are in. For example, if you had a file named sample.txt, to find how many lines there are, you would do:
wc -l sample.txt

This file has 11 lines. You can download this sample here.

wc -l is very useful, especially when you have a lot to do, and don’t want to open the file just to see how many lines there are.

What did you think of this article? Do you have anything to add? Let’s discuss it in the comments below.

Posted on Categories Linux

Leave a Reply

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