shell指令碼查看網路設定,shell指令碼查看

來源:互聯網
上載者:User

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;
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.