Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

3 bytes added, 15:11, 16 March 2021
INVESTIGATION 4: CONTROL FLOW STATEMENTS
# Save your editing session and exit the text editor<br>(eg. with vi: press '''ESC''', then type ''':wx''' followed by '''ENTER''').<br><br>[[Image:if-2.png|thumb|right|320px|Output of a shell script using the '''read''' command and the '''if''' control-flow statement.]]
# Issue the following Linux command to add execute permissions for your shell script:<br><span style="color:blue;font-weight:bold;font-family:courier;">chmod u+x if-2.bash</span><br><br>
# Run your shell script by issuing:<br><span style="color:blue;font-weight:bold;font-family:courier;">./if-2.bash</span><br><br>When prompted, make certain that the '''first number''' <br>is <u>greater than</u> the '''second number'''<br><br>
# Run the <span style="font-weight:bold;font-family:courier;">./if-2.bash</span> Bash shell script again.<br><br> When prompted, make certain that the '''first number''' is <u>less than or equal to</u> the '''second number'''<br>What happens?<br><br>Let's use an '''if-else''' statement to provide an appropriate alternative<br>if the condition is FALSE.<br><br>
# Use a text editor like vi or nano to create the text file called '''if-3.bash''' (eg. <span style="color:blue;font-weight:bold;font-family:courier;">vi if-3.bash</span>)<br><br>
13,420
edits

Navigation menu