Re: [CentOS] Sort logfiles on common lines?

2011-09-26 Thread Dotan Cohen
On Sun, Sep 25, 2011 at 22:43, John R Pierce pie...@hogranch.com wrote: uniq can count occurances.  will require two sorts.  one to get all similar errors adjacent, the other to sort by count order.   instead of using field selects, lets just clip the timestamps off up front...   cut -c 17- |

Re: [CentOS] Sort logfiles on common lines?

2011-09-26 Thread Dotan Cohen
On Sun, Sep 25, 2011 at 23:34, John R. Dennison j...@gerdesas.com wrote: Actually you are 2 full point releases behind; current is 5.7.  I would strongly suggest you update. Thanks. I will mention that to the sysadmin. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com

[CentOS] Sort logfiles on common lines?

2011-09-25 Thread Dotan Cohen
I have a huge mysql.log file full of errors. I'd like to sort it by the most common line, and work from there. I did go through the manpage for sort, and googled a bit, but I found nothing relevant. Here is an example of the output: [root@ log]# tail mysqld.log 110925 11:05:35 [ERROR]

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread John R Pierce
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]#

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread Frank Cox
On Sun, 25 Sep 2011 21:51:51 +0300 Dotan Cohen wrote: Is there a way to get the most common (unique) lines of the file? If you want what I think you want, a combination of cut and sort will do it. By the way, I'm not sure if this is RHEL or CentOS, or which version: I assume that it is one of

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread Dotan Cohen
On Sun, Sep 25, 2011 at 22:06, John R Pierce pie...@hogranch.com wrote: 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

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread Dotan Cohen
On Sun, Sep 25, 2011 at 22:10, Frank Cox thea...@sasktel.net wrote: Is there a way to get the most common (unique) lines of the file? If you want what I think you want, a combination of cut and sort will do it. Neither seem to have the most common line ability built in. I might have to resort

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread John R Pierce
On 09/25/11 12:18 PM, Dotan Cohen wrote: On Sun, Sep 25, 2011 at 22:06, John R Piercepie...@hogranch.com wrote: 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

Re: [CentOS] Sort logfiles on common lines?

2011-09-25 Thread John R. Dennison
On Sun, Sep 25, 2011 at 10:21:11PM +0300, Dotan Cohen wrote: Thanks! I is more up to date than I thought! [root@gastricsleeve html]# cat /etc/redhat-release CentOS release 5.5 (Final) Actually you are 2 full point releases behind; current is 5.7. I would strongly suggest you update.