//View Tip #304
Similar Tips
» Remove every file but one
» Stream shell commands to Twitter
» SVN resolve all conflicts
» Check memory and swap from command line
» Sort the lines of a file by length

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
#!/bin/bash
# by dj.r4iden
echo "Your ip Address is" `lynx --source http://www.formyip.com/ |grep The | awk {'print $5'}`


View Comments »




Comments 

Add your comment

Comments are currently disabled
ddd
why not just use ifconfig and sed|awk?
Posted 2008-09-19 03:22:25
John
Because generally you need to be root to use ifconfig.
Posted 2008-09-19 04:29:15
ddd
ifconfig eth0 | sed '/inet addr:/!d' | awk {'print $2'} | sed 's/addr://'
Posted 2008-09-19 12:43:48
snegtul
Or another way:
as a .bashrc alias
alias myip="links -dump http://www.formyip.com/ | grep \"Your IP\" | \
   sed 's/^[ \t]*//'"

ifconfig will only give you the local IP, you might be NAT'd and want to find the external IP of the network you're on.
Posted 2008-10-02 23:30:59
ddd
ah, NAT, you scoundrel.
Posted 2008-10-03 18:37:54

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit