Getip (script)

Getip is a shellscript that will retrieve your IP address from the command line

/sbin/ifconfig $1 | grep inet | awk '{print $2}' | sed 's/^addr://g'
 * 1) !/bin/bash
 * 2) get ip

To do it without any external commands (apart from ifconfig), or to get your Internet address if you are behind a NAT:

if [ "$1" = "-n" ] then ip=$(lynx -dump http://cfaj.freeshell.org/ipaddr.cgi) else if=$1  ## specify which interface, e.g. eth0, fxp0 system=$(uname) case $system in     FreeBSD) sep="inet " ;;      Linux) sep="addr:" ;; esac temp=$(ifconfig $if) temp=${temp#*"$sep"} ip=${temp%% *} fi
 * 1) The -n option retrieves the Internet IP address
 * 2) if you are behind a NAT

printf "%s\n" "$ip"
 * 1) CFAJ ###