1. 程式人生 > >想想怎麽取IP玩

想想怎麽取IP玩

shell linux獲取本機IP

ifconfig eth0|egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}'|sed -n "1p" ifconfig eth0|sed -n "2p"|awk '{print$2}'|cut -d ":" -f 2 ifconfig eth0|awk -F: '{print$2}'|sed 's/ //'|sed 's/ /\n/g'|awk 'NR==4{print}' ifconfig eth0|head -n 2|tail -n 1|cut -c 21-32 ifconfig eth0|grep "inet addr:"|awk -F: '{print$2}'|sed "s/Bcast//g" ifconfig eth0|awk "NR==2{print}"|cut -d: -f 2|tr -d "Bcast"

應該還有很多種方法 目前的所學只能寫一點出來

想想怎麽取IP玩