Re: IP address

Pàgina inicial

Reply to this message
Autor: Patrice Karatchentzeff
Data:  
A: guilde
CC: Guilde
Assumpte: Re: IP address
Le 19/10/07, Marc BERLIOUX<xmarc@???> a écrit :
> Dr P Dupre a écrit :
> > Bonsoir,
> >
> > Coment est -ce que je pourrais recuperer l'adresse IP (seulement) d'un
> > interface.
> > ifconfig ppp0
> > me donne inet addr:172.26.2.14 P-t-P:172.26.2.1 Mask:255.255.255.255
> > Je voudrais recupere uniquement 172.26.2.14
> >
>
> ifconfig ppp0 | grep 'inet adr' | cut -f2 -d':' | cut -f1 -d' '


Tiens, j'ai deux unilignes perl pour le faire :

ifconfig eth0 | perl -ane 'if (/inet adr/) { split(/:/,$F[1]) ; print $_[1] }'

ifconfig eth0 | perl -ane 'if (/inet adr/) { $F[1] =~ s/adr://; print $F[1] }'

PK

-- 
      |\      _,,,---,,_       Patrice KARATCHENTZEFF
ZZZzz /,`.-'`'    -.  ;-;;,_   mailto:p.karatchentzeff@free.fr
     |,4-  ) )-,_. ,\ (  `'-'  http://p.karatchentzeff.free.fr
    '---''(_/--'  `-'\_)