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: 3741011 • Letter: T

Question

The following shell script is used to check if the input IP address is invalid or not.
Hint: grep returns 0 if a pattern is found.

Fill in the Blanks!


#!/bin/bash
nums=$@
count=_______A._______ # Store the number of arguments from command line
nums=" "$nums" "
# Prints the number before sorting
echo -n "Original Numbers typed:"
for num in _______B._______
do
echo -n "$num "
done
echo
res=""
# Now do the Sorting of numbers
for n in `seq 1 $count`
do
min=_______C._______ # Get the first int from nums
for num _______D._______
do
if [_______E._______]
then
min=$num;
fi
done
res="$res $min"
nums=`echo "$nums"|sed _______F._______`
done
echo -n "Sorted Numbers:"
echo $res

Explanation / Answer

A.$#

B. ${nums[@]}

C. ${num[0]}

D. ${nums[@]}

E. '0,/99999999/ s/"$min"/'

F. "$min" -gt "$num"