Options

Redhat 7 scripting question

ally_ukally_uk Member Posts: 1,145 ■■■■□□□□□□
Dear gods of linux is there a one liner I can use to show a ip address of a system and by using awk and cut wizadry cut down the output to show just the ip address

So I can then create a menu driven script that can be used on all systems to show a i.p addr

:)
Microsoft's strategy to conquer the I.T industry

" Embrace, evolve, extinguish "

Comments

  • Options
    masqmasq Member Posts: 33 ■■□□□□□□□□
    Hi.
    You didn't provide enough info about your systems, whether they're ipv4 or ipv6, number of network interfaces, etc..
    But I guess this should work for you:
    $ ip addr | grep -Ei "inet.*eth[[:digit:]]" | tr -s " " | cut -f 3 -d " " | cut -f1 -d"/"
    
    2018:
    • RHCE
  • Options
    ally_ukally_uk Member Posts: 1,145 ■■■■□□□□□□
    Hey one network interface using ipv4 ethernet.

    Thank you for the reply :) would also be interesting to see some other solutions perhaps with using awk.

    Thats the beauty of Linux so many ways of getting things done.
    Microsoft's strategy to conquer the I.T industry

    " Embrace, evolve, extinguish "
Sign In or Register to comment.