Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I have the below lines like these, and I want to check how many lines I 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 any way to count them using any linux commands?

1 Answer

0 votes
by (36.8k points)

You can use the wc:

wc -l <filename>

This will output a number of lines in your <filename>:

$ wc -l /dir/file.txt

3272485 /dir/file.txt

Or, to omit the <filename> from the result use wc -l < <filename>:

$ wc -l < /dir/file.txt

3272485

You can also use the pipe data to wc as well:

$ cat /dir/file.txt | wc -l

3272485

$ curl yahoo.com --silent | wc -l

63

Want to be a Linux expert? Come and join this Linux course

Do check out the video below for better understanding of Linux from scratch

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 9, 2021 in Linux by blackindya (18.4k points)
0 votes
1 answer

31k questions

32.9k answers

507 comments

693 users

...