Changes

Jump to: navigation, search

Tutorial12: Shell Scripting - Part 2

3 bytes added, 09:31, 18 March 2021
INVESTIGATION 2: ADDITIONAL LOOPING STATEMENTS
# To demonstrate, <u>issue</u> the following set of '''commands''':<br><br><span style="color:blue;font-weight:bold;font-family:courier;">num1=5;num2=10<br>sum=$(($num1+$num2))<br>echo $sum<br><br>((product=$num1*$num2))<br>echo $product</span><br><br>Let's correct our '''for-6.bash''' shell script to correctly use math operations.<br><br>
# Use a text editor like vi or nano to edit the text file called '''for-6.bash''' (eg. <span style="color:blue;font-weight:bold;font-family:courier;">vi for-6.bash</span>)<br><br>
# Edit '''line 6''' and change to replace with the following:<br><span style="font-family:courier;font-weight:bold;">((value=value+1))</span><br><br>'''Note:''' For those familiar with other programming languages, you can achieve the same results by using: '''((value++))'''<br><br>
# 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 file and '''run this Bash shell script'''.<br>What do you notice? <br><br>
13,420
edits

Navigation menu