What does $@ mean in a shell script?
$*
expands to all parameters that were passed to that shell script.
$0
= shell script's name
$1
= first argument
$2
= second argument
...etc
$#
= number of arguments passed to shellscript
It's easy to find answer by yourself: man bash
→ /\$\*
:
Special Parameters
The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed.
- Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the
IFS
special variable. That is,"$*"
is equivalent to"$1c$2c..."
, wherec
is the first character of the value of theIFS
variable. IfIFS
is unset, the parameters are separated by spaces. IfIFS
is null, the parameters are joined without intervening separators.
It means all the arguments passed to the script or function, split by word.
It is usually wrong and should be replaced by "$@"
, which separates the arguments properly.