Question: Linux Script Tracing Problem A script file tracethis.sh has the code below. What will the output be for the following calls to the script file?

Linux Script Tracing Problem

Linux Script Tracing Problem A script file tracethis.sh has the code below.What will the output be for the following calls to the script

A script file tracethis.sh has the code below. What will the output be for the following calls to the script file? The commands are given in bold text: #!/bin/bash if [ $# -ne 1 ]; then echo "Error!" 1>&2 exit 1 if [ $1 -le 0 ]; then echo "Error!" 1>&2 exit 2 elif [ $1 -le 2 ]; then echo "1" else VAR1=1 VAR2=1 RESULT=$($VAR1+$VAR2)) i=3 while [ $i -lt $1 ); do VAR1=$VAR2 VAR2=$RESULT RESULT=$(($VAR1+$VAR2)) i=$(($i+1)) done echo $RESULT fi (a) What is the output of the following: $ tracethis.sh -1? (b) What is the output of $ echo $? after a)? (c) What is the output of the following: $ tracethis.sh 3? (d) What is the output of $ echo $? after c)? (e) What is the output of the following: $ tracethis.sh 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!