开发者

count the number of rows with similar columns values

Count the number of rows in a files with similar value in the last column.

   1 517904400201116629 ; 26122010 194609 ; 102 ; 10 ; FR ; M ; NA ; 0 ; (ART1-000010) The FR server timed out.
   1 517904400201116630 ; 26122010 194609 ; 101 ; 10 ; FR ; M ; NA ; 0 ; (ART1-000010) The FR server timed out.
   1 517904400201116631 ; 26122010 194609 ; 101 ; 10 ; FR ; M ; NA ; 0 ; (ART1-000010) The FR server timed out.
   1 517904400201256749 ; 26122010 163432 ; 131 ; 18326 ; FR ; H ; COLC9FMT_TLSIMPStationCheckPostSubscr.cpp ; 92 ; Post Subscriber 4187514772 is not valid for this event.
   1 517904400201261167 ; 26122010 170724 ; 131 ; 18326 ; FR ; H ; COLC9FMT_TLSIMPStationCheckPostSubscr.cpp ; 92 ; Post Subscriber 9052695914 is not valid for this event.
   1 517904400201271471 ; 26122010 181943 ; 131 ; 10 ; FR ; M ; NA ; 0 ; (ART1-000010) The FR server timed out.
   1 517905400201757204 ; 26122010 164743 ; 131 ; 18326 ; FR ; H ; COLC9FMT_TLSIMPStationCheckPostSubscr.cpp ; 92 ; Post Subscriber 9052695914 is not valid 开发者_如何转开发for this event.

The last values column keep changing. I want to add find out the number of line having the same last columns value

how to do this using awk?


If columns are separated by one or more space characters:

awk '{a[$NF]++} END{for (el in a) print a[el] " lines end with \""el "\""}' file | sort -nr

otherwise, you'll have to change the field separator with the option -F

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜