Open a text editor , copy and paste the following:
#! /bin/bash exip=`lynx -dump http://www.whatismyip.com | head -n 2` echo "$exip"
Save the txt ( for the sake of agrument we will refer the file as ip.sh)
From console type:
chmod a+x ip.sh
Now run the script like so:
./ip.sh (which will display something like the following)
Your IP Is XX.XXX.XXX.XX
I will explain what we just did in the script.
!# /bin/bash <- Tells what shell we using, this line is always here but /bin/bash may be changed, depending on your system
exip=`lynx -dump http://www.whatismyip.com | head -n 2` <- We setup a variable and run some console commands, lynx is a txt mode browser the we send it to head, which takes only the first to lines.
echo "$exip" <- We echo the content of exip variable to screen
chmoding to a+x just makes the file executable..
I know there a billion ways to do this, but it gets job done ...