"$*" != "$@"
* When the expansion occurs within double quotes, it expands to a single word.
@ When the expansion occurs within double quotes, each parameter expands to a separate word.
Without double quotes, $* = $@
test.sh
#!/bin/sh
for i in "$*"
do
echo $i
done
for i in "$@"
do
echo $i
done
for i in $*
do
echo $i
done
for i in $@
do
echo $i
done
# ./test.sh 1 2
1 2
1
2
1
2
1
2
ref. Bash Reference Manual - Special Parameters, Double Quotes
Leave a comment