I'm new in bash and I'm learning it, and I have a doubt about the real difference between the use of $@
and S*
.
I red here Bash Special Parameters
I understand that both expand to the positional parameters, but the difference occurs within double quotes.
By the way "$@" = "$1" "$2"..."$n"
could be different than "S*" = "$1$2...$n".
I try to understand it with a simple script:
if [ $# -gt 0 ]; then
echo "Your command line contains $# arguments"
else
echo "Your command line contains no arguments"
exit fi
echo "Params are: "
echo $@
echo $*
echo "$@"
echo "$*"
if I execute my script in the terminal like this ~./my_script par1 par2 par3
the result is always the same:
Params are:
par1 par2 par3
par1 par2 par3
par1 par2 par3
par1 par2 par3
Maybe I don't understand the real use of both special variables and If my example is correct or not. I'd like to figure out this point also with a good example.