Forum Moderators: phranque

Message Too Old, No Replies

Sort by IP address Apache access-log how?

         

born2run

3:47 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi, is there any unix command that'll sort my Apache access-logs file to find which IP address visited my website most? It's a log of about 24 hours.

I hope there is some way to figure this out. Thanks!

born2run

4:00 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi So I found this cmd on the search:

cat ./file |awk '{print $1}' |sort |uniq -c |sort -n |tail

It seems to give only top 10 however.. why not more?

born2run

4:04 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So just so that somebody gets helped here.. here is the cmd that works, it sorts out ip addresses by number:

cat ./file |awk '{print $1}' |sort |uniq -c |sort -n

phranque

4:32 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



"tail" puts out the end of the file/stdin.
"tail -n 50" outputs the last 50 lines, instead of the last 10 (the default)

cat ./file |awk '{print $1}' |sort |uniq -c |sort -n


i use this line often:
cut -f1 <./access_log|sort|uniq -c|sort -nr|less

born2run

4:44 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Great thanks!

born2run

4:48 am on Oct 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



phranque hi, what does your cmd do?