Can someone help me get this command work better:
wget -q -O- http://showipaddress.com | grep '<h1 id="ip">'
I want to grab just the ip address, nothing else.
Thanks
Printable View
Can someone help me get this command work better:
wget -q -O- http://showipaddress.com | grep '<h1 id="ip">'
I want to grab just the ip address, nothing else.
Thanks
Using xgrep, you can pull out the IP address with xpath.
I've used ip-address.com because it gives you the option of an XML output of the IP info. The above code is only for purposes of an example and you must seek permission of the site owner or consult their fair usage policy if you intend to use the as part of an automated process for commercial or non commercial purposes.Code:wget -q --user-agent="" -O - http://ip-address.domaintools.com/myip.xml | # no user agent
xgrep -x "/dnstools/ip_address/text()" | # pull out <ip_address>
grep --invert-match -i "<" # remove comment lines with inverted regex
Just the IP address:
wget -q -O - http://whatismyip.org/
1. Grab the output of http://checkip.dyndns.com/Code:wget -q -O- http://checkip.dyndns.com/ | tr -sc '0-9.' ' ' | sed -e 's/\s*//g'
2. Substitute all non-IP address characters into a single space with 'tr'. This will leave a single space on each side of the IP address.
3. Remove the spaces from the output with 'sed'.