-
-
Save laixintao/0fca9cb3f87f3cd5730ec02d41d90adf to your computer and use it in GitHub Desktop.
Difference between $* and $@
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "\$* in quotes..." | |
for v in "$*" | |
do | |
echo $v | |
done | |
echo "\$@ in quotes..." | |
for v in "$@" | |
do | |
echo $v | |
done | |
echo "\$* without quotes..." | |
for v in $* | |
do | |
echo $v | |
done | |
echo "\$@ without quotes..." | |
for v in $@ | |
do | |
echo $v | |
done | |
# OUTOUT: | |
# $* in quotes... | |
# hello world | |
# $@ in quotes... | |
# hello | |
# world | |
# $* without quotes... | |
# hello | |
# world | |
# $@ without quotes... | |
# hello | |
# world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment