Fastest way to extract IP:port occurances any text file?
Posted: 14 Aug 2013 11:44
Im hoping to find the fastest way to extract all occurrences of IP:port in almost any text file using pure batch file (if possible). I tried searching for a solution on google, but didn't find anything. Maybe there needs to be a little help from vbscript or powershell without downloading/installing extra software? Linux already has multiple native tools for this; such as: sed, awk, and grep.
textfile.txt
So, if I run the code against textfile.txt, the result would be:
6.240.54.222:22
72.222.7.123:8080
129.16.0.129:65080
I really wish findstr could show only matching string; instead of the entire line containing it. The below command doesn't really do many any good.
textfile.txt
Code: Select all
This is a text file which shows ipaddress:port randomly 6.240.54.222:22. The IP address can occur anywhere in the text file 72.222.7.123:8080 with no recognizable delimiters or surrounding characters such as brackets [] or colons:. So 129.16.0.129:65080 can appear anywhere in the text file.
So, if I run the code against textfile.txt, the result would be:
6.240.54.222:22
72.222.7.123:8080
129.16.0.129:65080
I really wish findstr could show only matching string; instead of the entire line containing it. The below command doesn't really do many any good.
Code: Select all
findstr ".*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\:[0-9][0-9]*" "D:\textfile.txt"