Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

659 bytes added, 10:58, 3 March 2021
INVESTIGATION 3: COMMAND SUBSTITUTION / MATH OPERATIONS
# Confirm that you are located in your '''home''' directory in your Matrix account.<br><br>
# To demonstrate the need for the '''( )''' construct, issue the following:<br><span style="color:blue;font-family:courier;font-weight:bold">echo "1 + 2"</span><br><br>What did you notice?<br><br>
# Issue the following (using that math construct):<br><span style="color:blue;font-family:courier;font-weight:bold">echo "$((1 + 2))"</span><br><br>What did you notice?<br>The '''$''' in front of the construct '''expands ''' the result of the calculation.<br><br># Issue the following commands demonstrating other types of math calculations:<br><span style="color:blue;font-family:courier;font-weight:bold">echo "$((2 - 3))"</span><br><span style="color:blue;font-family:courier;font-weight:bold">echo "$((2 * 3))"</span><br><span style="color:blue;font-family:courier;font-weight:bold">echo "$((2 / 3))"</span><br><span style="color:blue;font-family:courier;font-weight:bold">echo "$((2 ** 3))"</span><br><br>NOTE: You may notice that dividing 2 by 3 shows a zero result. To perform decimal calculations would require use of other commands like '''awk''' or '''bc''' (technique not covered in this course).<br><br>
# x
13,420
edits

Navigation menu