On Wed, Mar 25, 2009 at 11:10:01PM -0600, Dan Schaper (dscha...@ganymeade.com) wrote:
> #!/bin/bash > ip=`ifconfig $1 | grep "inet addr" | awk '{print $2}' | tr -d addr:` > echo Your ip on $1 is $ip Not that it really matters, but you don't need grep and tr: ip=`ifconfig $1 | awk '/inet addr/{sub(/addr:/,""); print $2}'` or even shorter ip=`ifconfig $1 | awk -F'[: ]+' '/inet addr:/{print $4}'` and unless you need the ip in a variable for other purposes, you can do away with the echo as well: ifconfig $1 | awk -F'[: ]+' '/inet addr:/{print "your ip on '$1' is "$4}' Also, it might be prudent to use full path for ifconfig, i.e. /sbin/ifconfig, as /sbin may not be in $PATH. -- Tapani Tarvainen -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org