

Getting Unique Counts From a Log File - gpapilion
http://blog.hypergeometric.com/2013/06/22/getting-unique-counts-from-a-log-file/

======
joshbaptiste
It amazes me at work how many people just violate UUOC/UUOG

ie..

    
    
      cat file | grep bar | awk '{ print $1 }' | sort | uniq
    

which can simply be

    
    
      awk '/bar/ { print $1 | "sort -u"}' file

~~~
casca
I've done this for single-use pipelines when built up because the nature of
the data is unfamiliar. It usually starts with

    
    
       cat file | less
    

and then

    
    
       cat file | grep bar | less
    

and then

    
    
       cat file | grep bar | awk '{ print $1 }' | less
    

and so on.

But if it's going to be used more than once then it does seem odd to have the
unnecessary commands. Maybe "advanced" awk (beyond print $1) is unknown to
people?

~~~
ibotty
if you are only doing 'print $1' you should be using cut. but whatever.

------
jonjenk
There is a great wiki book on this subject.

[http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_U...](http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line)

~~~
pessimizer
Hopefully you've already submitted this, because I'm about to. Looks great.

------
steffan
I believe the word you want is 'Glean'

