||Department of Engineering
Up: Shell Programming
Previous: Wildcard characters
It is easy to write a script that takes arguments (options) from the
Type this script into a file called args.
echo this $0 command has $# arguments.
echo They are $*
The echo command echoes the rest of the line to the screen by default.
Within a shell script, $0 denotes the script's name, $1 denotes
the first argument mentioned on the command line and so on. Make the script
executable then try it out with various arguments. For example, if
args first another
- $# would be replaced by 2, the number of arguments,
- $0 would be substituted by args,
- $* would be substituted by first another, (`*' having a wildcard