Next: Looping and Making Choices
Up: Shell scripts
Previous: Shell scripts
- Positional parameters can be used to pass information to a script:
directly, with parameters representing command-line arguments, or indirectly,
using set and command substitution (see below), letting the parameters
represent the output of a command
- Within the script, we refer to the first argument as $1, the second
argument as $2, and so on
- $0 stands for the name of the command itself
- $* stands for all arguments from $1 on up
- These numbered arguments are referred to as positional parameters
- $# represents the number of arguments
- set is used to assign values to positional parameters
Example:
set `who am i`
echo $1
Note: previously assigned values for positional parameters will be erased!!
Roger Hampel
Mon Feb 2 09:39:25 MET 1998