I don't know if people will find this interesting, but I got so excited I needed to share this with you guys... I needed a script to return me only my ip in a determined interface, but I didn't know anything about awk... so, I got some reading on man awk
and after a long and hard time
I came up with this :
code - Script name: getmyip
#! /bin/sh
DEV=$1
if [ ! $DEV ]; then
DEV=eth1
fi
IP=`ifconfig | grep $DEV -A 1 | grep "inet addr" | awk '/addr/ {FS = ":"; split($2,a,":"); print a[2]}'`
echo "$IP"
end code
Just put that on my /usr/bin and when I need my ip address just type getmyip eth1 for my NAT ip and getmyip ppp0 for my internet IP (PPPoE dsl)
hope this can be helpful... If anyone has a better and easier solution please! tell me