Question
Unix/Lunix Programming Exercise 5 Read the following script interactive_mode and answer the question. # interactive mode if [[ -n $interactive ]]; then while true; do
Unix/Lunix Programming
Exercise 5
Read the following script interactive_mode and answer the question.
# interactive mode
if [[ -n $interactive ]]; then
while true; do
read -p "Enter name of output file: " filename
if [[ -e $filename ]]; then
read -p "'$filename' exists. Overwrite? [y/n/q] > "
if [[ "$REPLY" == "y" ]]; then
break
elif [[ "$REPLY" == "q" ]]; then
echo "Program terminated."
exit
fi
elif [[ -z $filename ]]; then
continue
else
break
fi
done
fi
Assume that interactive is not empty.
What are the next five commands that will be executed if user provides an empty filename?
What is the next three commands being executed if user supplies a non-existing filename?
What is the next two commands being executed if user supplies an existing filename?
If user then provides n, what are the next three commands being executed?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started