Count number of lines in a file – Linux

 

There are different ways to count number of lines in a file.

I will show the some of commands to count number files in file.

With wc:

$ wc -l <inutFileName>

Counting number of lines with wc -l is most common and popular way.

With awk:

$ awk 'END{ print NR }' <inutFileName>

With sed:

$ sed -n '$=' <inutFileName>

With grep:

$ grep -c "" <inutFileName>

-Sany

Advertisements

One comment on “Count number of lines in a file – Linux

  1. is content. Thanks for sharing with your readers..It’s quite evident that you have really researched this information and provided valid points for readers to consider. I can appreciate the effort you put into all th..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s