Shell Scripting: How to execute Shell Scripts?

Shell scripts are written to execute a set of commands and to group them. The scripts will have the following special line


This is an indication that the shell script is used in bash shell and that it should be called for command execution.

To know the path of the bash shell, type
$ cat /etc/shells

Now, let us begin with “helloshell” shell script

$ vi helloshell

Type in the following lines of the code and save it

# helloshell script
echo “Enter your name …”
read yourname
echo “Welcome $yourname! Path to you SHELL > $SHELL”

Give execute permission to the shell script
$ chmod +x helloshell

To execute the shell script, type
$ . helloshell (or)
$ ./helloshell (or)
$ sh helloshell

TIP 1: To comment any lines in a shell script, use the character ‘#’
TIP 2: To easily identify a shell script, save the file with ‘.sh’


Written by kurinchilamp

Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *