Re: group by & count command?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 25 Nov 2003 14:22:08 -0600, Steve Cowles wrote
> On Tue, 2003-11-25 at 13:01, Mike Vanecek wrote:
> > I have a bash command that is essentially grep | sed | sort. It creates a file
> > of sorted records. What I would like to do next is create a report that lists
> > each unique item and its count.
> > 
> > 1
> > 1
> > 1
> > 2
> > 3
> > 3
> > 
> > would be
> > 1 - 3
> > 2 - 1 
> > 3 - 2
> > 
> > Can this be done via a bash command and if yes, how? Otherwise, I would assume
> > it needs to be fed to a perl script?
> 
> Type: man uniq
> 
> In particular, the -c option will give you a good start a generating
> your final report. i.e. given the results of your script are stored 
> in report.txt

> your_script | uniq -c
> 1 3
> 2 1
> 3 2

Perfect, thank you. I modified an idea by Ulrich Scholler to 

(zcat /var/log/maillog.1.gz; cat /var/log/maillog) | grep "reject" | sed -re
's/.*\[([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\].*/\1/' | sort | uniq -c

quickly shows troublesome ips.


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux