Counting lines in a file/doc.

0 votes

I have document like this. Is there a way I could count lines in this document using a terminal command?

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
Mar 5 in Linux Administration by Atul
• 10,240 points
27 views

1 answer to this question.

0 votes

you can do this by using word count cmmand:

wc -l <filename>

output the number of lines in <filename> using:

$ 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 do this while piping data to wc as well:

$ cat /dir/file.txt | wc -l
3272485
$ curl yahoo.com --silent | wc -l
63
answered Mar 5 by DareDev
• 6,810 points

Related Questions In Linux Administration

0 votes
1 answer

Writing a heredoc to a file in a script

try to use tee: tee newfile <<EOF line 1 line 2 line ...READ MORE

answered May 20 in Linux Administration by Shubham
• 13,290 points
46 views
0 votes
1 answer

Script file name in a Bash script

$0 will give you the complete basename. ...READ MORE

answered Jun 20 in Linux Administration by Shubham
• 13,290 points
19 views
0 votes
1 answer

Input file name in the mapper in a Hadoop program

Try this inside your mapper : FileSplit fileSplit ...READ MORE

answered Jul 23 in Linux Administration by Shubham
• 13,290 points
44 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Change the output colour of echo

Try using ANSI escape codes as the following; Black ...READ MORE

answered Jul 12 in Linux Administration by Shubham
• 13,290 points
32 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
80 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 20 in Linux Administration by DareDev
• 6,810 points
32 views
0 votes
1 answer

setting a variable output from a bash command

You can use $(command), which in my ...READ MORE

answered Feb 15 in Linux Administration by DareDev
• 6,810 points
77 views