截取网卡IP地址

方法一:

ifconfig eth1|awk 'NR==2 {print $2}'

方法二“”

ifconfig eth1|grep -Po "(?<=inet )\d{1,3}(.\d{1,3}){3}"

ifconfig eth1|grep -Po '(?<=inet ).*(?= net.*)'

方法三:

ifconfig eth1|sed -n '2s/inet//gp'|sed 's/net.*//g'

其他:

ifconfig eth1|grep 'inet '|awk '{print $2}'
posted @ 2017-09-05 18:48  Achxku  阅读(323)  评论(0编辑  收藏  举报