Get “Top n” occurences in text files

I searched a way to get the “Top n” occurrences in a text file. The solution is described in http://encodable.com/tech/blog/2008/12/17/Count_IP_Addresses_in_Access_Log_File_BASH_OneLiner.

cat /path/to/access.log |awk '{print $1}' |sort |uniq -c |sort -n |tail
In my case I had a logfile containing method calls and I wanted to know the "Top 5" of them.
Advertisements
This entry was posted in Bash/Shell, Linux. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s