Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Understanding of the parameters passed by script

Shulou Source: shulou.com Published: 2022-06-01 05:56:12 10月04日 Update

${! #} enter the last parameter

$# number of input parameters

$* enter all parameter strings and treat all parameters as one string.

$n output n parameters

$? The exit status of the previous command, or the return value of the function.

$the current Shell process ID. For Shell scripts, it is the process ID where these scripts are located.

The difference between $* and $@

Both $* and $@ indicate that all arguments passed to a function or script, when not contained in double quotes (""), are marked with "$1"$2". Outputs all parameters in the form "$n".

But when they are enclosed in double quotes (""), "$*" takes all the parameters as a whole and outputs all parameters in the form of "$1 $2 … $n"; "$@" separates the parameters as "$1"$2"... Outputs all parameters in the form "$n".

Tags: Parameters output script form input function character string quotation mark process number command is location whole state Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn MySQL Xiaomi Microsoft