r/ScriptSwap • • Dec 17 '17

[help] simple shell script

Hi everyone,

I need help with a simple shell script that can count the number of http 4xx responses per unique ip address in the server access logs at /var/logs/httpd/access_logs

I found this online but doesn’t help much since it tell me the count for all response codes without IP

cat access_log | cut -d ‘“‘ -f3 | cut -d ‘ ‘ -f2 | sort |uniq -c | sort -rn

Please can someone help me? Thank you!

2 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/isaaclw Dec 19 '17

Thanks. Also remember (for /u/Alkanes123 ) that with uniq, you need to have the duplicate entries right next to each other. Hence most instances of uniq are prefaced with a sort