法一:
ifconfig eth1 |grep "inet addr:" |awk '{print $2}'|cut -c 6-
eth* :指定的网卡
法二:
ifconfig | grep -Eo \([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\} |sed -n '1p'
这个不用指定网卡,用1p :1-->n来取第n个ip法一:
ifconfig eth1 |grep "inet addr:" |awk '{print $2}'|cut -c 6-
eth* :指定的网卡
法二:
ifconfig | grep -Eo \([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\} |sed -n '1p'
这个不用指定网卡,用1p :1-->n来取第n个ip