Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

206 bytes added, 10:25, 3 September 2020
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 '''hello''' shell script.<br><br>What shell does the shell script indicate is running?<br>This is because there is NO '''she-bang line''' at the top of the shell You should notice that this script; therefore, it is being run in the '''Bourne Bash Shell''' (i.e. , although the <u>current shell</u>)is the Bourne shell.<br><br>Let's '''add''' # It is a '''she-bang line''' good idea to rename your shell script to include an extension to indicate that the top of this file is a Bash Shell script file. Issue the following linux command to rename your shell script file so it :<ubr><span style="color:blue;font-weight:bold;font-family:courier;">forcesmv hello hello.bash</uspan><br> the <br># Run your renamed shell script to run in the '''Bash Shell''' instead of the Bourne Shellby issuing:<br><span style="color:blue;font-weight:bold;font-family:courier;">./hello.bash</span><br><br># Use a text editor to edit the shell script called '''hello.bash'''<br><br>
# Add the following line to the TOP of the file:<br><span style="font-family:courier;">#!/bin/bash</span><br><br>
# Run your '''hello''' shell script.<br><br>What shell does the shell script indicate is running?<br><br>This is because of the shebang line indicating to run the shell script in the Bash shell although you ran this script within the Bourne Shell.<br><br>Let's add a she-bang line to the top of this shell script file so it forces the shell script to run in the Bash Shell instead of the Bourne Shell.<br><br>
 
 
 
# Enter the following linux command to return to your Bash shell: <span style="color:blue;font-weight:bold;font-family:courier;">exit</span><br><br>
# Use a text editor to edit the shell script called '''hello.bash'''<br><br>
13,420
edits

Navigation menu