This document explains how to create and execute Bourne shell scripts. You will also learn about
shell builtins, input/output redirection, and quoting as well as the difference between interactive and subshell scripting.
What is a script? A script is a set of commands, either in a ?le, or typed in at the command line, that per-
form multiple operations on a ?le or ?les. Another term for scripts that might be familiar to you is a
How do they work? To run a ?le as a script, the ?le must have the execution bit set. As you’ll recall from
the Unix I course, this means the ?le looks like this when you look at it:
As an alternative to setting the execution bits on a ?le and then running that ?le directly, it is also possi-
ble to read commands from a non-executable ?le into the current shell. Because this runs the current
shell as an interpreter on the ?le being read, it should be used very carefully, since any environment
variables set or changed in the script will be altered in the current shell. As a result, it is safer to run the
script in its own subshell.