Welcome to WebmasterWorld Guest from 54.198.221.13

Forum Moderators: Ocean10000 & incrediBILL & phranque

Sort by IP address Apache access-log how?

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

Senior Member

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

joined:Dec 19, 2004
posts:679
votes: 8


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!
4:00 am on Oct 7, 2017 (gmt 0)

Senior Member

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

joined:Dec 19, 2004
posts:679
votes: 8


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?
4:04 am on Oct 7, 2017 (gmt 0)

Senior Member

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

joined:Dec 19, 2004
posts:679
votes: 8


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
4:32 am on Oct 7, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11076
votes: 106


"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
4:44 am on Oct 7, 2017 (gmt 0)

Senior Member

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

joined:Dec 19, 2004
posts:679
votes: 8


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

Senior Member

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

joined:Dec 19, 2004
posts:679
votes: 8


phranque hi, what does your cmd do?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members