Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 done

Explanation / 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote