Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

998 bytes added, 08:08, 19 July 2020
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Save your editing changes and exit your text editor.<br><br>
# Issue the following linux command to change to the c-shell (a different shell than the default Bash):<br><span style="color:blue;font-weight:bold;font-family:courier;">csh</span>
# Issue the following linux command to confirm you are in the c-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 c-shell.<br><br>
# Run your '''hello.bash''' 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 c-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>
# Save your editing changes and exit your text editor.<br><br>
# Run your '''hello.bash''' shell script.<br><br>Take time to view the output and the values of the environment variables.<br><br>
# Issue the following linux command to add your current directory to the PATH environment variable:<br><span style="color:blue;font-weight:bold;font-family:courier;">PATH=$PATH:.</span><br><br>
# Issue the following linux command to confirm that the current directory "." has been added to the PATH environment variable:<br><span style="color:blue;font-weight:bold;font-family:courier;">echo $PATH</span><br><br>
# Run the hello.bash by just shell script name (i.e. to not use ./ prior to shell script name).<br><br>The shell script should run just by name.
# Exit your Matrix session, and log back into your Matrix session.<br><br>
# Re-run the hello.bash shell script by just using the name.<br><br>What did you notice?<br><br>The setting of the PATH variable only worked in the current session only. If exit the current Matrix session, then the recently changed settings for environment variables are lost. You will learned in Week 12 how to set environment variables in startup files.<br><br>
# x
 
 
In the next investigation, you will ...
13,420
edits

Navigation menu