LISTSERV mailing list manager LISTSERV 16.0

Help for LINUX-L Archives


LINUX-L Archives

LINUX-L Archives


LINUX-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LINUX-L Home

LINUX-L Home

LINUX-L  2007

LINUX-L 2007

Subject:

Finding most frequent occurance of strings in a log; an easier way?

From:

Burton Windle <[log in to unmask]>

Reply-To:

Platform Independent Linux List! <[log in to unmask]>

Date:

Fri, 30 Nov 2007 16:19:07 -0500

Content-Type:

TEXT/PLAIN

Parts/Attachments:

Parts/Attachments

TEXT/PLAIN (20 lines)

Often times, I need to find the most frequent occurance of some string in 
a log file; most spammed person, most commonly hit file in an apache log, 
etc. Right now I'm using a series of sed, awk, grep -c, echo and a bash 
loop to do something that is ugly, difficult to type, and difficult to 
explain to a newbie, but works well.  Does anybody know of a better way to 
do the same thing?

Example:

cat ~/mail/SPAM | grep "X-Original-To:" | sort | sed 's/X-Original-To: //' > /tmp/spam-to
for i in `cat /tmp/spam-to | uniq `; do echo -n "$i " && grep -c $i /tmp/spam-to ; done > /tmp/spam-to-counts
cat /tmp/spam-to-counts | awk '{print $2" "$1}' | sort -rn | head

And end up with a nicely sorted list of the most-frequently spammed email 
adddress at my domain, sorted by hit-count. (I know its ugly, and 
likely ineffeciant, which is why I'm looking for something better)


-- 
Burton Windle                           [log in to unmask]

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager