Processing of parameter processing-shell incoming parameters
$#
The number of arguments passed to the script
$*
Displays all parameters passed to the script in a single string. Unlike positional variables, this option parameter can be more than 9
$$
The current process ID number for the script to run
$!
Process ID number of the last process running in the background
[email protected]
With the $#
same, but quoted when used, and returns each parameter in quotation marks
$-
Displays the current options used by the shell, same as the SET command function
$?
Displays the exit status of the last command. 0 means there is no error, and any other value indicates an error.
Variable meaning
$0
Script Name
$1
Positional parameters #1
$2
- $9
Position parameter #2-#9
${10}
Positional parameters #10
$#
Number of positional parameters
"$*"
All positional parameters (as a single string) *
"[email protected]"
All positional parameters (each as a separate string)
${#*}
The number of command-line arguments passed to the script
${#@}
The number of command-line arguments passed to the script
$?
return value
$$
Process ID (PID) of the script
$-
Flags passed to script (using set)
$_
Last parameter of the previous command
$!
Process ID (PID) of the last job running in the background
Built-in variables for common shell scripting