shell指令碼查看網路設定,shell指令碼查看
#!/bin/bashifconfig|grep -E 'eth|inet'|grep -Ev '(inet6|127.0.0.1)'|sed 's/ /\n/g'|awk NF|grep -Ev '(inet|encap|Link|HWaddr)'|sed 's/00:/MAC:/g';route|grep default|awk '{print "\nGATEWAY:"$2}'cat /etc/resolv.conf|grep nameserver|awk '{print "DNS:"$2}'
shell指令碼執行中怎自動讀取需要配置的檔案?
假設安裝命令為install.sh,制定的檔案名稱為target.sh,則可以執行如下命令:
./install.sh < target.sh
哪位linux幫忙寫一個linux的shell指令碼是對於查看更改網卡設定檔的不勝感激
寫了一部分,實在是不想寫了。20分不安逸得:
declare -a array ;array=(`ifconfig | grep encap | awk -F " " '{ print $1 }'`); echo "You have ${#array[@]} network card" ;echo "Network card list:"; for var in ${array[@]}; do echo $var; done; echo "Display the configure of Networkcard?(y/n)" ; read dpc; if [ $dpc == "y" ]; then echo "Please choice which interface you want to display:"; echo "0::all";numc=1 ;for chin in ${array[@]} ; do echo "$numc::$chin" ; numc=$[numc+1] ; done ;echo "You Input is:" ;read choice;if [ $choice -gt ${#array[@]} ] ; then echo "You Input Error"; sleep 10; fi; if [ $choice -eq 0 ] ; then for ethvar in ${array[@]}; do ifconfig $ethvar; done ; else ifconfig ${array[$choice-1]} ;fi;fi;