The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Counting characters, words, spaces, punctuations, etc. ajay41aj High Level Programming 4 03-06-2009 01:02 PM
Counting with Awk saint2006 Shell Programming and Scripting 4 02-03-2009 05:10 PM
counting words then amending to a file iago UNIX for Dummies Questions & Answers 1 09-10-2007 08:32 PM
Counting words in a file r0mulus Shell Programming and Scripting 1 10-24-2002 09:32 AM
Counting LOC in C amatsaka High Level Programming 1 06-04-2002 03:18 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-24-2009
FOBoy FOBoy is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 5
counting words

if i have a long list of data, with every line beginning with an ip-address, like this:

62.165.8.187 - - [24/Oct/2002:23:13:42 +0200] "GET /bestandnaam.html HTTP/1.1" 200 5848 "http://www.domeinnaam.nl/bestandnaam.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

how do i count which ip-adresses are mentioned the most?

i don't know which ip-adresses to search so i can't give an input how many times a specific word is mentioned, i just want to know which are mentioned the most.
  #2 (permalink)  
Old 09-24-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
An example how it could be done:
Code:
$> cat infile
11.4.1.31
10.10.10.1
10.123.1.5
10.10.10.1
10.123.1.5
11.4.1.31
10.10.10.1
11.43.1.30
9.30.111.7
11.43.1.30
11.4.1.31
9.30.111.7
11.4.1.31
11.4.1.31
10.123.1.5
$> awk '{_[$1]+=1} END{for(a in _){print a,_[a]}}' infile| sort -t" " -k2,2r
11.4.1.31 5
10.10.10.1 3
10.123.1.5 3
11.43.1.30 2
9.30.111.7 2
  #3 (permalink)  
Old 09-24-2009
chakrapani's Avatar
chakrapani chakrapani is offline
Registered User
  
 

Join Date: Sep 2009
Location: Asia
Posts: 88
Check with this one

Code:
awk '{ print $1 }' | sort | uniq -c  /path/to/logfile.log
  #4 (permalink)  
Old 09-24-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,175
chakrapani probably meant:

Code:
# Top 10 occurances of IP address
awk '{print $1}'  /path/to/logfile.log | sort | uniq -c | sort -n -r | head -10
Reply

Bookmarks

Tags
count words, sed, wc

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0