I have a text file containing several lines of IP's and Ports with 3 sets per line.
IP1=220.127.116.11 PRT1=100 IP2=18.104.22.168 PRT2=200 IP3=22.214.171.124 PRT3=300 IP1=12.34.56 PRT1=1000 IP2=126.96.36.199 PRT2=200 IP3=188.8.131.52 PRT3=300
I want to read in each line, see if PRT1 matches a specific port, if so then print out IP2 and PRT2.
So far I have it reading in a line, and then matching PRT1 (I just check to see if the line contains 'PRT1=x' using strstr).
However I am not sure how to get the values of IP2 and PRT2 as I dont know how to extract unknown values (as we do not know what we are looking for unlike finding PRT1) and these values are not restricted to being a certain length.
Can anyone advise me on how to do this?
Thanks in advance :)