This works also just incase you don't have perl installed: # for i in $(ifconfig -a); do echo $i | awk -F "addr:" '$2 != "127.0.0.1" && $2 > 0 {print $2}'; done
List ips on system, works on bash, sh, ksh Ron -----Original Message----- From: Danny [mailto:[EMAIL PROTECTED] Sent: Thursday, June 15, 2006 8:52 AM To: Perl-beginners Subject: Re: Getting ip address > Danny wrote: > > Hi list, > > > > I am trying to get the ip address from each of my NIC's (only the ip address) from ifconfig and then > > mailing the addresses to a remote mailbox. The problem is that I am making one BIG > > stuff-up out of it and I am too embarrassed to post my script here. The more I > > try, the harder it seems to get, and the more I get confused. > > > Danny > > Can I suggest something like - I pinched this a while back from someone: > > $ perl -le '/inet (?:addr:)?(\S+)/ > and $1 ne "127.0.0.1" and push @a,$1 foreach `ifconfig -a`; print "@a"' > > Pipe the output to mail or the like. > Thank you. It is exactly what I was looking for. Danny -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>