Positional Parameters
$0, $1, $2, etc.
Positional parameters, passed from command line to script, passed to a function, or set to a variable (see Example 4-5 and Example 15-16)
$#
Number of command-line arguments [4] or positional parameters (see Example 36-2)
$*
All of the positional parameters, seen as a single word
Note
"$*" must be quoted.
$@
Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.
Note
Of course, "$@" should be quoted.
Other Special Parameters
$-
Flags passed to script (using set). See Example 15-16.
Caution
$!
PID (process ID) of last job run in background
$_
Special variable set to final argument of previous command executed.
$?
Exit status of a command, function, or the script itself.
$$
Process ID (PID) of the script itself. The $$ variable often finds use in scripts to construct "unique" temp file names.
$0, $1, $2, etc.
Positional parameters, passed from command line to script, passed to a function, or set to a variable (see Example 4-5 and Example 15-16)
$#
Number of command-line arguments [4] or positional parameters (see Example 36-2)
$*
All of the positional parameters, seen as a single word
Note
"$*" must be quoted.
$@
Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.
Note
Of course, "$@" should be quoted.
Other Special Parameters
$-
Flags passed to script (using set). See Example 15-16.
Caution
$!
PID (process ID) of last job run in background
$_
Special variable set to final argument of previous command executed.
$?
Exit status of a command, function, or the script itself.
$$
Process ID (PID) of the script itself. The $$ variable often finds use in scripts to construct "unique" temp file names.
Comments
Post a Comment
https://gengwg.blogspot.com/