13,420
edits
Changes
→INVESTIGATION 3: exit AND break STATEMENTS
# Save your editing session and exit the text editor (eg. with vi: press '''ESC''', then type ''':x''' followed by '''ENTER''').<br><br>
# '''Add execute permissions''' for this Bash shell script.<br><br>
# Issue the following command (without arguments):<br><span style="color:blue;font-weight:bold;font-family:courier;">./break-1.bash</span><br><br>When prompted, enter several '''invalid''' and '''valid''' integers. Then enter '''valid integers ''' NOT containing the value of '''5'''. <br>Finally enter the integer with the value of '''5'''.<br><br>What happens?<br><br>Let's use the '''break''' statement with the '''for''' loop.<br><br>
# Use a text editor like vi or nano to create the text file called '''break-2.bash''' (eg. <span style="color:blue;font-weight:bold;font-family:courier;">vi break-2.bash</span>)<br><br>
# Enter the following lines in the '''break-2.bash''' shell script:<br><span style="font-family:courier;font-weight:bold;">#!/bin/bash<br><br>for x<br>do<br><br> if [ $x = "uli101" ]<br> then<br> break<br> fi<br> echo "Argument is: $x"<br>done<br><br>echo<br>echo "Shell script has been completed"</span><br><br>