此脚本修改Linux下/etc/sysconfig/network-scripts/ifcfg-ethX网卡文件中的网卡一、网卡二的IP地址(IPADDR)、子网掩码(NETMASK)信息
#!/bin/sh
PROC=/bin/sedFILE_PATH1=/etc/sysconfig/network-scripts/ifcfg-eth0FILE_PATH2=/etc/sysconfig/network-scripts/ifcfg-eth1IP_PRIMAL1=`grep -i ipaddr $FILE_PATH1|awk -F "=" '{printf $2 }'`MASK_PRIMAL1=`grep -i netmask $FILE_PATH1|awk -F "=" '{printf $2}'`IP_PRIMAL2=`grep -i ipaddr $FILE_PATH2|awk -F "=" '{printf $2 }'`MASK_PRIMAL2=`grep -i netmask $FILE_PATH2|awk -F "=" '{printf $2}'`IP_MODI1=192.168.1.200MASK_MODI1=255.255.255.0IP_MODI2=192.168.2.200MASK_MODI2=255.255.255.0$PROC -e "s/$IP_PRIMAL1/$IP_MODI1/g" -e "s/$MASK_PRIMAL1/$MASK_MODI1/g" $FILE_PATH1>ifcfg-eth0.bak$PROC -e "s/$IP_PRIMAL2/$IP_MODI2/g" -e "s/$MASK_PRIMAL2/$MASK_MODI2/g" $FILE_PATH2>ifcfg-eth1.bakcp -pf ./ifcfg-eth0.bak $FILE_PATH1cp -pf ./ifcfg-eth1.bak $FILE_PATH2cat $FILE_PATH1cat $FILE_PATH2service network restart