Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

17 bytes added, 11:58, 3 March 2021
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Issue the following linux command to run your shell script in the ''Bourne Shell'':<br><span style="color:blue;font-weight:bold;font-family:courier;">./hello</span><br><br>You should see that you are currently running the shell script in 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>
# 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;font-weight:bold;">#!/bin/bash</span><br><br>This is referred to as a '''she-bang line'''. It forces this script to be run in the '''Bash Shell'''.<br>When your Bash Shell script finishes execution, you are returned to your current shell that you are using<br>(which in our case in Matrix, is still the Bash shell).<br><br>
# '''Save''' your editing changes and '''exit''' your text editor.<br><br>
# While in the Bourne shell, issue the following linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">./hello</span><br><br>You should notice that the shell name is running in the '''bash''' shell.<br><br>
13,420
edits

Navigation menu