How do I search, sort & count log file content?

Posted on 2009-04-29
Last Modified: 2013-12-16
I have email log files, which I would like to be able to extract multiple email address in a given column ( awk '{print $12}' ) & a count of the total number of occurrences for each. Essentially a top ten (or top 100) list. Any advice would be great.
Question by:buster2007
    LVL 40

    Expert Comment

    you can do

    awk '{print $12}' file | sort | uniq -c

    Author Comment

    That's exactly what I was looking for, perfect, thank you very much!
    LVL 68

    Expert Comment


    ... and to have only a 'top ten' list, use
    awk '{print $12}' file | sort | uniq -c | head -10
    LVL 84

    Accepted Solution

    if you want the top 10 counts
    awk '{print $12}' file | sort | uniq -c | sort -nr | head

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now