[CentOS] Sort logfiles on common lines?

John R Pierce pierce at hogranch.com
Sun Sep 25 19:06:29 UTC 2011


On 09/25/11 11:51 AM, Dotan Cohen wrote:
> ...
> 110925 13:09:43 [ERROR] /usr/libexec/mysqld: Incorrect key file for
> table './ox_data_summary_ad_hourly.MYI'; try to repair it
> [root@ log]# wc -l mysqld.log
> 20686 mysqld.log
> [root@ log]# cat mysqld.log | grep ERROR | wc -l
> 20332
> [root@ log]#
>
>
> Is there a way to get the most common (unique) lines of the file?

sort -k 3 | uniq -f 2


which will sort starting at field 3, and then print lines that are 
unique, skipping the first 2 fields, where fields by default are blank 
separated.



-- 
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast




More information about the CentOS mailing list