How will you count the number of lines and words in a file in Unix?

We can use wc (word count) command for counting the number of lines and words in a file. The wc command provides very good options for collecting statistics of a file. Some of these options are:

l : This option gives line count
m : This option gives character count
c : This option gives byte count
w : This option gives word count
L: This option gives the length of the longest line

In case we give more than one files as input to wc command then it gives statistics for individual files as well as the total statistics for all files.

Leave a Reply

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