I am trying to keep this to a one-liner... How can I take the IP addresses as the are looping through and push them into another command? I have this part already.
I am am trying to also incorporate a "geoiplookup" for each of the IP's into the loop.
I am trying to get the output to look like this:
6 168.123.123.123 DE, Germany
5 134.23.43.56 US, United States
1 45.65.7.32 US, United States
The closest I have gotten so far will run the IP's but the variable of the IP is lost and can not be written out properly;
Thanks!
Bash:
netstat -antu | awk '$5 ~ /[0-9]:/{split($5, a, ":"); ips[a[1]]++} END {for (ip in ips) print ips[ip], ip | "sort -k1 -nr"}'
I am am trying to also incorporate a "geoiplookup" for each of the IP's into the loop.
I am trying to get the output to look like this:
6 168.123.123.123 DE, Germany
5 134.23.43.56 US, United States
1 45.65.7.32 US, United States
The closest I have gotten so far will run the IP's but the variable of the IP is lost and can not be written out properly;
Bash:
netstat -antu | awk '$5 ~ /[0-9]:/{split($5, a, ":"); ips[a[1]]++} END {for (ip in ips) print ip | "sort -k1 -nr"}'| xargs -I{} geoiplookup {}
Thanks!