Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions