http://qs1969.pair.com?node_id=440318


in reply to Re: [off-site] Bash + Perl oneliners basics
in thread [off-site] Bash + Perl oneliners basics

I bet mine runs with 1/4th the CPU.
Except that for small to medium sized files, it doesn't matter and the additional programming (and debugging) time dwarves the running time. And for really long files, your program might actually be slower, or even fail to finish as it will consume significant amounts of memory. The elegant one-liner, consisting of several tools that do one thing well won't suffer from memory problems, as 'sort' knows when to switch to using temporary files.

Having said that, I would have written the one-liner as:

awk '{print $6}' /var/log/httpd/access_log | sort | uniq -c | sort -n | head -10