How to count the lines and get the number of lines in a text file under Linux?

by Yang Yang on April 14, 2009

Share This Article:
Subscribe to Kavoir: blog feed

Type:

wc -l foo.txt

And the system returns:

12 foo.txt

Meaning foo.txt has 12 lines.

To count unique lines a file has:

sort -u foo.txt | wc -l

Which will simply exclude all extra lines that are identical.

Share This Article:
Subscribe to Kavoir: blog feed

You should also read:

Leave a Comment

Previous post:

Next post: