Oussema Cherni bio photo

Oussema Cherni

Linux Systems engineer & Internet side-preneur From Tunisia

Twitter Google+ LinkedIn Instagram Github

In this example, we will parse the apache log of a specific date(19/april/2014) and time(between 13:00 and 13:08)

awk '$4>"[19/Apr/2014:13:00:" && $4<"[19/Apr/2014:13:08:"' /var/log/apache2/access.log | |awk '{print $1}' | sort | uniq -c | sort -gr

The output will be something like that

    528 157.x.229.88
276 93.4.x.241
196 86.214.x.38
195 77.x.178.225
192 92.90.x.62
190 109.x.96.247
181 197.31.x.150
164 105.158.x.175
157 88.x.195.41
155 84.x.192.57
154 78.113.x.152
152 109.210.144.102
150 80.x.162.139
141 88.x.103.78
138 90.84.x.217