Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

No change in size, 17 February
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Confirm that you are located in your '''home''' directory in your Matrix account.<br><br>
# Use a text editor to edit the shell script called '''hello'''<br><br>
# Add the following line to the bottom of the file:<br><span style="font-family:courier;">echo "The current shell you are using is: $(ps -o cmd= -p $$|cut -d" " ' ' -f1)"</span><br><br>'''NOTE:''' This command displays the '''name''' of the ''shell'' that the shell script<br>is running within. The command within '''$( )''' uses a technique known as "''command substitution''"<br>which you will learn about in '''week 12'''.<br><br>
# '''Save''' your editing changes and '''exit''' your text editor.<br><br>
# Issue the following linux command to run this shell script with the Bourne Shell (i.e. '''sh'''):<br><span style="color:blue;font-weight:bold;font-family:courier;">sh hello</span><br><br>You should see the output of the command that you are located in shows '''sh''' (i.e. the '''Bourne Shell''').<br><br>'''NOTE:''' Due to the fact that shells (and their features) have '''evolved''' over a period of time,<br>an error may occur if you include a ''NEWER'' shell feature (e.g. ''Bash Shell'') in your shell script,<br>but run it in an ''OLDER'' shell (e.g. ''Bourne Shell'').<br><br>You can add a '''special comment''' to the BEGINNING of the FIRST line of your shell script to<br>'''force''' it to run in the shell you want (for example: the Bash shell).<br><br>
12,886
edits

Navigation menu