root@test:/home/test/shell# ifconfig |cut -c 1,2,3,4,5,6|tr -d ' '|tr -s '\n'
eth0
lo
wlan0
取得ip地址
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:'
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]'
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9]"
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9.]"
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9.]*"
inet 地址:127.0.0.1 掩码:255.0.0.0
inet 地址:192.168.6.100 广播:192.168.6.255 掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
127.0.0.1
255.0.0.0
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
127.0.0.1
255.0.0.0
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig wlan0|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig wlan0|grep -P 'inet 地址:[^ ]*' -o|grep -o "[0-9.]*"
192.168.6.100