views:

127

answers:

5

Hey there ...

I have lines like these, and I want to know how many lines I actually have...

09:16:39 AM  all    2.00    0.00    4.00    0.00    0.00    0.00    0.00    0.00   94.00
09:16:40 AM  all    5.00    0.00    0.00    4.00    0.00    0.00    0.00    0.00   91.00
09:16:41 AM  all    0.00    0.00    4.00    0.00    0.00    0.00    0.00    0.00   96.00
09:16:42 AM  all    3.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00   96.00
09:16:43 AM  all    0.00    0.00    1.00    0.00    1.00    0.00    0.00    0.00   98.00
09:16:44 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
09:16:45 AM  all    2.00    0.00    6.00    0.00    0.00    0.00    0.00    0.00   92.00

Is there anyway to count this using linux commands

Thanks in advance !

+11  A: 

Use wc.

wc -l <file>

outputs the number of lines.

+4  A: 
wc -l <file.txt>

Or

command | wc -l
John Kugelman
+3  A: 

Use wc:

wc -l <filename>
Vivin Paliath
+5  A: 

Use

$ wc -l file

to count all line or

$ grep -w "pattern" -c file  

to filter and count only lines with pattern, or with -v to invert match..

$ grep -w "pattern" -c -v file 

See man grep to take a look in -e,-i and -x args...

olarva
`wc -c` will give you the number of bytes in the input. `wc -l` is what you want for a line count.
Vineet
Yes, sorry and thanks...
olarva
+2  A: 

there are many ways. using wc is one.

wc -l file

others include

awk 'END{print NR}' file

sed -n '$=' file (GNU sed)

grep -c ".*" file
ghostdog74