View network configurations using shell scripts
#!/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}'
How can I automatically read the files to be configured during shell script execution?
If the installation command is install. sh and the file name is set to target. sh, run the following command:
./Install. sh <target. sh
Which of the following linux statements can help you write a linux shell script? Thank you very much for checking and changing the NIC configuration file.
I did not want to write a part. 20 points not comfortable:
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 $ {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;