On Mon, 21 Jun 1999, scratch wrote: > On Mon, 21 Jun 1999, R. Brock Lynn wrote: > > > > /sbin/ifconfig | grep P-t-P | cut -d: -f2 | cut -d" " -f1 > > > > nice, now can you do that with a perl one-liner? :) > > Something like this? > perl -e 'print (`/sbin/ifconfig` =~ /inet addr:(.*?)\s/);'
Beat me to it! Oh well, i can clean it up to make it work right... perl -e 'print (`/sbin/ifconfig` =~ /inet addr:(.*?)\s P-t-P:/, "\n");' Or how about one for every interface? This seems to work... perl -e 'for(`/sbin/ifconfig`){/^\S+/ and $i=$& or /inet addr:(\S+)/ and print"$i\t$1\n"}' If you don't want the interface name, it gets even shorter: perl -e 'for(`/sbin/ifconfig`){/inet addr:(\S+)/ and print"$1\n"}'