sorting and limiting a sub-top-n
Joost van Baal
joostvb at logreport.org
Wed Jul 11 00:57:47 CEST 2001
Hi Joost,
On Tue, Jul 10, 2001 at 12:06:29PM +0200, Joost Bekkers wrote:
>
> I have:
>
> user0 100
> site1 5
> site2 10
> site3 7
> site4 58
> site5 10
> user1 80
> site1 20
> site6 60
>
> I want:
>
> user0 100
> site4 58
> site2 10
> site5 10
> user1 80
> site6 60
> site1 20
If you have
5 user0 site1
10 user0 site2
7 user0 site3
58 user0 site4
10 user0 site5
20 user1 site1
60 user1 site6
you could do
sort -k2,2 -k1,1n
to get
5 user0 site1
7 user0 site3
10 user0 site2
10 user0 site5
58 user0 site4
20 user1 site1
60 user1 site6
.
This works with GNU sort, as well as with the sort shipped with OpenBSD.
I believe this is about what you want. If not, please let us know.
(How did you get your initial table?)
To limit a sub top-n I guess I would use perl or awk. Dunno of any
simpler trick. (You might want to do the whole thing, including the
sort stuff, in perl, btw.)
BTW: I included your cisco logfile parser in cvs, it will be shipped with
next lire release. Didn't write any report_ scripts for that yet, though.
Bye,
Joost
--
To UNSUBSCRIBE, email to questions-request at logreport.org with a subject of
"unsubscribe". Trouble? Send an email with subject "help" to
questions-request at logreport.org
More information about the Questions
mailing list