Skip to main content
1 of 4

How to retrieve IP adresses?

I am checking a log file to retrieve ip adresses plus how many times a log failed. Now, I want to also check for how many times the log was accepted.

How do I extend

sed -nr '/Failed/{s/.*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/;p}'| sort | uniq -c 

to also check for accepted passwords? Something like

sed -nr '/Accepted|Failed/{s/.*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/;p}'| sort | uniq -c 

But instead of having an "or" between Accepted and Failed I would like to get a count result that would look like this:

123.53.163.22 3 2 -> IP, Failed, Accepted

This is realted to How to retrieve IP addresses of possible ssh attackers?