Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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


Comment on Re^2: [off-site] Bash + Perl oneliners basics
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-09-23 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls