awk counting number of occurences

Hi,

I am trying to count the max number of occurences of field1 in my apache log

example:

10.0.0.1 field2 field3
10.0.0.2 filed2 field3
10.0.0.1 field2 field3
10.0.0.1 field2 field3

awk result to print out only the most occurence of field1 and number of occurence
and field1 is dynamic variable, i want to be able to use the same awk command if the log
shows 10.0.0.x

10.0.0.1 3

many thanks

Pretty straight forward and covered a lot of times in this forum.

awk '{tot[$1]++}END{for (ip in tot) print ip, tot[ip]}' file
$ 
$ cat file1
10.0.0.1 field2 field3
10.0.0.2 filed2 field3
10.0.0.1 field2 field3
10.0.0.1 field2 field3
$ 
$ cut -d' ' -f1 file1 | sort | uniq -c
      3 10.0.0.1
      1 10.0.0.2
$ 

tyler_durden

Thank you very much to all , awk array is a power tool.