I am trying to get my external Ip using cygwin on a Windows 7 box. I am almost there but I am having an issue with the sed substitution syntax. As you see, I am getting the IP, but I don't want the </body> part of the output.
C:\>wget -q http://checkip.dyndns.org -O index1.html && sed "s/.*:\(.*\)<.*/\1/" index1.html
Without the -q switch the output is:
<html><head><title>Current IP Check</title></head><body>Current IP Address: 188.8.131.52</body></html>
How do I have to change the sed command? Instead of creating the index1.html file, I also tried unsuccessfully to use pipe and grep, but failed to get that working properly. Alternative approaches would also be appreciated, but I would like to know what I am doing wrong with the sed commands. I have tried many different variations, but just can't seem to get just the IP address.