How to count lines in a document?

后端 未结 24 1471
慢半拍i
慢半拍i 2020-11-27 08:47

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.0         


        
24条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 09:26

    To count all lines use:

    $ wc -l file
    

    To filter and count only lines with pattern use:

    $ grep -w "pattern" -c file  
    

    Or use -v to invert match:

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

    See the grep man page to take a look at the -e,-i and -x args...

提交回复
热议问题