Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

9 bytes added, 10:25, 17 February 2021
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Issue the following linux command to change to the Bourne Shell (a different shell than the default Bash):<br><span style="color:blue;font-weight:bold;font-family:courier;">sh</span><br><br>
# Issue the following linux command to confirm you are in the Bourne Shell:<br><span style="color:blue;font-weight:bold;font-family:courier;">echo $SHELL</span><br><br>You should see the output of the command that you are located in the Bourne Shell.<br><br>
# Run your shell script: <span style="color:blue;font-weight:bold;font-family:courier;">./hello</span><br><br>What shell does the shell script indicate is running?<br>You should notice that this script is being run in the Bourne shell.<br><br>Although your shell script should work, it is recommended to force your shell script to run in a '''specific ''' shell. <br>This helps prevent your shell script encountering errors when run in the incorrect shell (i.e. syntax not recognized in a specific shell).<br><br>
# Edit your '''hello''' shell script using a text editor.<br><br>
# Insert the following line at the '''beginning''' of the '''first''' line of your hello file:<br><span style="font-family:courier;">#!/bin/bash</span><br><br>This is referred to as a '''she-bang line'''. It forces the script to be run in the Bash Shell. When your Bash Shell script finishes execution, you are returned to your current shell that you are using (which in our case in Matrix, is still the Bash shell).<br><br>
13,420
edits

Navigation menu