In an attempt to get out of writer’s block, I’m going to post my way of quickly looking up my public IP address from the command line. I know that there is a million ways to do this and thousands out there have a shorter line blah blah… so again, this is just my preference. This came in handy at work the other day when I shared it with a colleague who dropped it into a function in a file under /etc/profile.d/ on mutiple systems we work with. This way, any user of any system can have access to it.
echo -e "\n`wget -nv -O - http://checkip.dyndns.org/ 2>&1 | \ sed -n -e 's/.*\(.*\).*/\1/p'`\n"
Sample output of the above would be:
Current IP Address: 188.8.131.52
And of course, if you prefer to get just the IP address itself, it’s a simple modification, just change the sed part to:
sed -n -e 's/.*\(.*\)\s\(.*\).*/\2/p'`\n"