Friday 14 September 2012

Count the number of lines in a file using terminal

Problem:

I would like to count the number of lines in a file.

Solution:

An easy way to count the number of lines in a file in Linux or OS X is to use the 'wc' command in terminal. For instance:

cat myfile.txt | wc -l 

Reference:

The 'wc' command can also do a bunch of other useful things. You can find out more by googling, looking at the command's man page, or clicking the following reference: http://linux.about.com/library/cmd/blcmdl1_wc.htm

No comments:

Post a Comment