Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

118 bytes added, 13:00, 5 March 2021
INVESTIGATION 3: COMMAND SUBSTITUTION / MATH OPERATIONS
# Use a text editor to create a Bash shell script called '''dog-years.bash'''<br><br>
# Add the following lines to the beginning of this file:<br><span style="font-family:courier;font-weight:bold;">#!/bin/bash<br>echo<br>dogFactor=7<br>read -p "Please enter your age (in years): " humanYears<br>((dogYears = humanYears * dogFactor))<br>echo "You age in dog-years is: $dogYears"<br>echo<br></span><br>
# Save your editing changes and exit your text editor.<br><br>[[Image:mathops1.png|thumb|right|275px|Output of a shell script with math operations using the '''math construct'''.]]
# Issue the '''chmod''' command to add execute permissions for the user for the '''dog-years.bash''' file.<br><br>
# Issue the following to run the user-variables.bash Bash shell script:<br><span style="color:blue;font-weight:bold;font-family:courier;">./dog-years.bash</span><br><br>Enter <u>your</u> age to see what happens.<br><br>
13,420
edits

Navigation menu