What does $* exactly mean in a shell script?
For example consider the following code snippet
$JAVA_HOME/bin/java/com/test/Testclass $*
What does $* exactly mean in a shell script?
For example consider the following code snippet
$JAVA_HOME/bin/java/com/test/Testclass $*
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.
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
IFSspecial variable. That is,"$*"is equivalent to"$1c$2c...", wherecis the first character of the value of theIFSvariable. IfIFSis unset, the parameters are separated by spaces. IfIFSis null, the parameters are joined without intervening separators.
$* 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