The following shell script is used to check if the input IP address is invalid o
ID: 3809433 • Letter: T
Question
The following shell script is used to check if the input IP address is invalid or not. Rs = 1 while [$rs -gt 0]; do clear echo -n Please input the ip read ip #use expr to check if the input IP address follows the IP address pattern is IP = if; then replace each dot by a space in string ip ip = isvalid = 0; #loop over the words in string ip for n in; do if [-0 $n -1t 0]; then echo "ERROR: The number of the IP should not be greater less than 255 and less than 0" break; done if; then echo'----- This is a valid IP-'. Fi else echo "ERROR: The IP format you in is wrong, the format should be like 192.168.100.1 fi echo echo -n Press 0 to exit and other numbers to continue....." read rs doneExplanation / Answer
This is to find out whetehr the given ip is valid or not.
A. `[[ $ip =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]] && echo "1" || echo "0"`
B. $isip -ne
C. `echo $ip | sed "s/./ /g"`
D. $ip
E. $n -gt 255
F. isvalid=1
G. $isvalid -eq 0
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.