环境:CentOS6.8-2.6.32-x86_64bit
网卡:eht0 eth1 lo

#!/bin/bash
#creation for rich
#time for 2017-11-22

[ -d /etc/sysconfig/network-scripts ]&& \
cd /etc/sysconfig/network-scripts ||exit
ls|grep ifcfg|nl

read -p "pls select you num:{1|2|3..}" num

if [ $num -eq 1 ];then
cat ifcfg-eth0|grep IPADDR|awk -F [=] '{print $2}'
elif [ $num -eq 2 ];then
cat ifcfg-eth1|grep IPADDR|awk -F [=] '{print $2}'
elif [ $num -eq 3 ];then
cat ifcfg-lo|grep IPADDR|awk -F [=] '{print $2}'
else
echo "pls input correct num.."
exit
fi