| Text-only | Table of Contents (frame/ no frame) |
| (11) Arguments |
|
These are often filenames, but can be interpreted by the script in any way. Options
are often specified using the "-flag" convention used by most Unix programs, and a ksh command
getopts is available to help parse them.
The shell expands wildcards and makes variable and
command substitutions as normal, then parses the resulting words by whitespace (actually
special variable $IFS), and places the resulting text strings into the
positional variables
as follows:
$0, $1, $2, ... $9
shift, or $*, $@. The variable $0 contains the name of the
script itself.
${10}, ${11}, ...
shift
shift N" will shift N arguments at once.
$#
$*
$@
a1 a2 "a3 which contains spaces" a4set command, followed by a set of arguments, creates a new set of
positional arguments. This is often used, assuming the original arguments are no longer needed, to parse
a set of words (possibly using different field separators). Arguments may be reset any number of times.
Example: pickrandom display, text
Selects a random file from a directory.
Uses the ksh RANDOM feature.
| arguments.src last modified Sep 14, 2005 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |