1: #!/bin/sh 2: PS4="\#> " 3: set -x 4: gcc -Wall -o hello2 hello2.c 5: ./hello2 ece449 6: exit |
Create the above script file in a text editor with the name first.
The first line is a “magic” code that identifies the file as a shell script and identifies the shell to be used to run the script.
The last line ensures that the script returns a sensible exit code. Exit codes are rarely checked when scripts are run interactively, as we will be doing, but may be checked when invoked by other scripts.
You can invoke a script in two ways
1> sh first
Make the script excutable for all users by running the chmod
2> chmod +x first
Then execute the script calling it by name.
3> ./first
Maintained by John Loomis, last updated 2 February 2010