[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

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

Hi,
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.
Thanks.
0
buster2007
Asked:
buster2007
1 Solution
 
omarfaridCommented:
you can do

awk '{print $12}' file | sort | uniq -c
0
 
buster2007Author Commented:
That's exactly what I was looking for, perfect, thank you very much!
0
 
woolmilkporcCommented:

... and to have only a 'top ten' list, use
 
awk '{print $12}' file | sort | uniq -c | head -10
0
 
ozoCommented:
if you want the top 10 counts
awk '{print $12}' file | sort | uniq -c | sort -nr | head
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now