Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

88 bytes added, 10:50, 11 March 2021
INVESTIGATION 4: CONTROL FLOW STATEMENTS
# Issue the following Linux commands at the Bash shell prompt to assign values to several variables:<br><span style="color:blue;font-weight:bold;font-family:courier;">course="ULI101"<br>number1=5<br>number2=10</span><br><br>
# Issue the following Linux command to test a condition:<br><span style="color:blue;font-weight:bold;font-family:courier;">test $course = "ULI101"</span><br><br>The '''$?''' variable is used to store an exit status of the previously command issued (including the test command).<br>If the exit status is '''zero''', then it indicates a TRUE value and if the status is '''non-zero''', then it indicates a FALSE value.<br><br>
# Issue the following Linux command to view the status of the previously-issued '''test''' command:<br><span style="color:blue;font-weight:bold;font-family:courier;">echo $?</span><br><br>Based on its the ''exit status'' value, is the result TRUE or FALSE?<br><br># Issue the following Linux command to test another condition:<br><span style="color:blue;font-weight:bold;font-family:courier;">test $course = "uli101"</span><br><br>Based on the ''exit status'' value, is the result TRUE or FALSE?<br><br>
# Issue the following Linux command to view the status of the previously-issued '''test''' command:<br><span style="color:blue;font-weight:bold;font-family:courier;">echo $?</span><br><br>The value is non-zero (FALSE) since UPPERCASE characters are different than lowercase characters.<br><br>
# Issue the following Linux command to test another condition:<br><span style="color:blue;font-weight:bold;font-family:courier;">test $course != "uli101"</span><br><br>
13,420
edits

Navigation menu