Which terminal command to get just IP address and nothing else?

后端 未结 29 1271
春和景丽
春和景丽 2020-12-04 06:16

I\'m trying to use just the IP address (inet) as a parameter in a script I wrote.

Is there an easy way in a unix terminal to get just the IP address, rather than loo

29条回答
  •  -上瘾入骨i
    2020-12-04 06:43

    On Redhat 64bit, this solved problem for me.

    ifconfig $1|sed -n 2p|awk '{ print $2 }'|awk -F : '{ print $2 }'
    

提交回复
热议问题