There are two ways you can execute your shell scripts. Once you have created a script file:

Method 1

Pass the file as an argument to the shell that you want to interpret your script. 

Step 1 :  create the script using vi, ex or ed

For example, the script file show has the following lines

echo Here is the date and time

date  

$ sh show

Here is the date and time

Sat jun 03 13:40:15 PST 2006

Make your script executable using the chmod command. 

When we create a file, by default it is created with read and write permission turned on and execute permission turned off. A file can be made executable using chmod.

Step 1 :  create the script using vi, ex or ed

For example, the script file show has the following lines

echo Here is the date and time

date 

Step 2 : Make the file executable

             $ chmod u+x script_file

            $ chmod u+x show

Step 3 : To run the script, just type the filename 

            $ show

Here is the date and time

Sat jun 03 13:40:15 PST 2006