Cat Test
218.79.251.215--[23/may/2006:08:57:44 +0800] "Get/fg172.exe http/1.1" 206 2350253
220.178.150.3--[23/may/2006:08:57:40 +0800] "Get/fg172.exe http/1.1" 200 2350253
59.42.2.185--[23/may/2006:08:57:52 +0800] "Get/fg172.exe http/1.1" 200 2350253
219.140.190.130--[23/may/2006:08:57:59 +0800] "Get/fg172.exe http/1.1" 200 2350253
221.228.143.52--[23/may/2006:08:58:08 +0800] "Get/fg172.exe http/1.1" 206 719996
221.228.143.52--[23/may/2006:08:58:08 +0800] "Get/fg172.exe http/1.1" 206 713242
221.228.143.52--[23/may/2006:08:58:09 +0800] "Get/fg172.exe http/1.1" 206 1200250
Awk
awk ' {print '} ' test|uniq-c
Python
#!/usr/bin/env pythonfile = open (' Test ') done = 0list_ip = []while not done: line = file.readline () if line != ': line = line.strip (' \ n ') line_list = line.split (' ', 1) list _ip.append (line_list[0]) else: done = 1file.close () ip_test = list (Set (LIST_IP)) For ip in ip_test: print "%s %s"  %  (List_ip.count (IP), IP)
This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1575010
Python Statistics log IP occurrences