13,420
edits
Changes
→INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Re-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 Bash Shell, although the current shell is the Bourne shell.<br><br>
# It is a good idea to rename your shell script to include an extension to indicate that the file is a Bash Shell script file. <br>Issue the following linux command to rename your shell script file:<br><span style="color:blue;font-weight:bold;font-family:courier;">mv hello hello.bash</span><br><br>
# Run your renamed shell script for confirmation by 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>
# Issue the following Linux command to confirm you have returned to the Bash shell: <span style="color:blue;font-weight:bold;font-family:courier;">echo $SHELL</span><br><br>
# Use a text editor to edit the shell script called '''hello.bash'''<br><br>
# Add the following lines to the bottom of the file:<br><span style="font-family:courier;">echo "The current username is: $USER"<br>echo "The current directory location is: $PWD"<br>echo "The current user's home directory is: $HOME</span><br><br>