log file processing

I seem to have been doing lots of this kind of thing recently.

grep "FOUND query" bak0*b_hac-server.log | awk '{print $8}' | awk 'BEGIN { FS = "|" }; { print $6 }' | sort | uniq -c

Remember, usually you want to sort before uniq.

One Comment

  1. steveo
    Posted February 5, 2009 at 12:01 am | Permalink

    | sort | uniq -c | sort -n
    will sort them, put the counts on, and then sort by count. I tend to add that 2nd sort most of the time.
    Kudos for your use of awk. I’ve never gotten comfortable with it myself.

Post a Comment

Your email is never published nor shared. Required fields are marked *