alanK
06-16-2006, 01:40 PM
Hi all,
I am trying to write a script that sorts a list of IP addresses, but still cannot get the regex to work. It's a bash script and the IPs are in the form of:
xxx.xxx.xxx.xxx:xxxx , :xxx is the port number.
What I am trying to do is once I get the list to count all matching IPs and list only once:
xx xxx.xxx.xxx.xxx
where xx is the number of occurrences of the xxx.xxx.xxx.xxx IP.
You can get the list if you do:
netstat --tcp -an | grep [0-9] | awk '{print$5}' | sort -n
Can someone help me with constructing the regex or give me an idea where to look for an answer? :)
Thanks
AK
I am trying to write a script that sorts a list of IP addresses, but still cannot get the regex to work. It's a bash script and the IPs are in the form of:
xxx.xxx.xxx.xxx:xxxx , :xxx is the port number.
What I am trying to do is once I get the list to count all matching IPs and list only once:
xx xxx.xxx.xxx.xxx
where xx is the number of occurrences of the xxx.xxx.xxx.xxx IP.
You can get the list if you do:
netstat --tcp -an | grep [0-9] | awk '{print$5}' | sort -n
Can someone help me with constructing the regex or give me an idea where to look for an answer? :)
Thanks
AK
