next up previous contents
Next: Running the Script Up: Programming the Shell Previous: Variables

A Simple Script

    #!/bin/sh
    echo "Hello World."
    exit 0
The first line of every script should start with a hash sign followed by an exclamation mark. This means ``use the program that follows to run this script". In this example, the program used to run the above script is /bin/sh, or the Bourne shell. The program could have been /bin/csh for the C shell, or /bin/ksh for the Korn shell, or any other program that could interpret the commands that follow.

The first line may also contain flags for the program. Examples of such flags are

-v
This causes every line to be displayed as it is executed.
-x
Prints the commands and their parameters as they are executed. Useful for debugging.
-f
For the C shell. Inhibit execution of .cshrc.

The second line of the program simply displays the string Hello World.

REMEMBER: every script should start with #!shell_name where shell_name is the name of the shell in which the script is written.





Claude Cantin
Sun Sep 1 02:02:26 EDT 2002