UseIfconfigRemove the NICEth0of theIpAddress
method 1:sed
[Email protected] ~]# ifconfig eth0 |sed-nr ' 2s#.*dr:|bca.*# #gp '
10.0.0.200
[Email protected] ~]#
method 2:sed
[Email protected] ~]# ifconfig eth0 |sed-nr ' 2S#.*DR: (. *) BCA.*#\1#GP '
10.0.0.200
[Email protected] ~]#
method 3:sed+cut
[Email protected] ~]# ifconfig eth0 |sed-n ' 2p ' |cut-d ': '-f2 |cut-d '-f1
10.0.0.200
[Email protected] ~]#
method 4:awk
[[email protected] ~]# ifconfig eth0 |awk-f ' [:]+ ' Nr==2{print $4} '
10.0.0.200
[Email protected] ~]#
method 5:awk
[Email protected] ~]# ifconfig eth0 |awk-f ' addr:|bcast: ' Nr==2{print $} '
10.0.0.200
[Email protected] ~]#
......
<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<< Day Changes
This article is from the "Qizhong" blog, make sure to keep this source http://qizhong.blog.51cto.com/12933988/1953680
Linux regular expression take-up IP