wgetIP – Shell script to find your IP Address

wgetIP is a simple shell script that extracts ip address from ifconfig.me and uses grep, sed, cut, awk for text processing, and wget for http request. I wrote it just for fun ^_^

After you save the script, open your terminal and run below commands.

chmod +x wgetIP.sh
# This should output something like 'IP:'

Basically what it does is download and write index.html to its current working directory, find the line with ‘ip_address”‘ on it, change all ‘>’ to whitespaces for use of awk that will print the next charaters after 5th found space and then use the delimiter ‘<' to find the ip address. Alternative simplest command that can check your ip address is by using curl.Try this: curl ifconfig.me. Install curl and its libraries and your good to go.