Douglas Milanez escreveu:
>> Vê se ajuda:
>> # ifconfig eth0 | awk '/inet end.:/ { print $3 }'
>> 192.168.0.128

Este não é bom porque usa end. que muda para addr. Contráriamente au que 
já foi dito e constestado, o LANG=C não funciona sempre.

>> #ifconfig eth0 | grep inet | tr -s " " | cut -f4 -d" "
>> 182.168.0.128

aqui não funcionou. aparece o ipv4 e o ipv6, a saída do meu ifconfig é 
assim:
eth0      Link encap:Ethernet  Endereço de HW 00:1E:58:45:E9:13
           inet end.: 10.0.0.33  Bcast:10.0.0.255  Masc:255.255.255.0
           endereço inet6: fe80::21e:58ff:fe45:e913/64 Escopo:Link

> Os comandos ajudaram sim, mas gostaria de algo mais transparente pra
> terminal e distros, ex: No meu Slack o ifconfig retorna "inet addr",
> já no Ubuntu fica: "inet end"...

Assim funciona bem, mas ainda não sei se é 100% genérico:

ifconfig eth0 | egrep "^ *inet"  | tr -s " " | cut -f4 -d" "

Alain

Responder a