test.txt:
this is the http ip : 1.1.1.1:678 blah blah.com2
this is the https ip : 1.1.1.2:654 blah blah.com2
this is the http ip : 1.1.1.4:456 blah blah.com2
the sever this is the http ip : 1.1.1.4:456 blah blah.com2
From the above text file, I want to grep only IP addresses:port number that starts with "http ip" as shown below.
It should print :
1.1.1.1:678
1.1.1.4:456
I have tried with following python code:
import re
file_open = open("test.txt", 'r')
for i in file_open:
if re.findall(".*http(.*)",i):
print i[0]
If I run the above python code, it prints :
2
2
2
Any idea to fix this please?