Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: [off-site] Bash + Perl oneliners basics

by Anonymous Monk
on Mar 17, 2005 at 09:50 UTC ( #440318=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440318]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2016-10-23 17:36 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (301 votes). Check out past polls.