On Tue, Jun 25, 2013 at 11:23 PM, Andy Bradford <[email protected]> wrote:
> Thus said "Ryan Simpkins" on Tue, 25 Jun 2013 22:18:29 -0600:
>
>> Look at that. Joseph has percentages. You Perl guys are always showing
>> off. ;-)
>
> How do you know he didn't do it with awk? (besides the fact that this is
> Joseph Hall we're talking about :-)
>
> $ fc -l 1 | awk '{ a[$2]++ } END { for (b in a) printf("%8d %8.2f%% %10s\n",
> a[b], 100 * a[b] / NR, b) }' | sort -k 1r | head -10
> 153 32.83% authpf
> 60 12.88% exec
> 28 6.01% whois
> 26 5.58% ssh
> 24 5.15% tmux
> 20 4.29% lynx
> 18 3.86% ls
> 13 2.79% sntpclock
> 13 2.79% awk
> 12 2.58% cd
>
> Yes, I left the line count off, but it would be trivial to add.
I love awk, it's like a nice subset of perl that's actually small and
simple enough to remember how to use between the odd times that I need
to reach for a "rubbish lister".
I recently needed to do some statistical analysis on some data logs I
captured from some devices I was testing. The log format was very
close to being compatible with gnuplot and R, but I needed to change
the format slightly and apply some data grouping and filtering before
it was ready to feed into the analysis tools.
After a quick refresher course with the awk manual, I was quickly
slicing and dicing the data and generating awesome graphs and boxplots
and the like. I even got the script modified a bit to group the data
several different ways from a single pass through the input file.
Whenever I have to make sense of some huge pile of logged data, awk is
the first thing I reach for. If you don't know awk, you should learn
it! Right now!
--Levi
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/