Linux-练习-取IP

1.grep :ifconfig eth0 | grep -o '^[^6]* addr:[0-9.]*' | grep -o [0-9.]*

2.sed :ifconfig eth0 | sed -nr 's#^.*dr:(.*)  B.*$#\1#g'p

3.sed :ifconfig eth0 | sed -nr "/^.*dr:(.*)  B.*/s##\1#"p

4:awk :ifconfig eth0 | awk -F '[ :]+' 'NR==2{print $4}'

5:ifconfig eth0 |awk '/addr:[[:digit:]]/''{print $2}' |sed 's/addr://g'

 

posted @ 2017-08-22 09:34  TimeTree  阅读(172)  评论(0编辑  收藏  举报