$*当被双引号引用的时候 会把所有的参数看成是一个字符串,不被引用的时候,把参数分开处理 $@不管被双引号引用或者不被引用,都把每个参数看成是一个字符串 index=1 # Initialize count. echo "Listing args with /"/$*/":" for arg in "$*" # Doesn't work properly if "$*" isn't quoted. do echo "Arg #$index = $arg" let "index+=1" done # $* sees all arguments as single word. echo "Entire arg list seen as single word." echo index=1 # Reset count. # What happens if you forget to do this? echo "Listing args with /"/$@/":" for arg in "$@" do echo "Arg #$index = $arg" let "index+=1" done # $@ sees arguments as separate words. echo "Arg list seen as separate words." echo index=1 # Reset count. echo "Listing args with /$* (unquoted):" for arg in $* do echo "Arg #$index = $arg" let "index+=1" done # Unquoted $* sees arguments as separate words. echo "Arg list seen as separate words." exit 0 输出结果为: jiawei@ubuntu:~/Documents/shell$ ./Operator.sh one two three Listing args with "$*": Arg #1 = one two three Entire arg list seen as single word. Listing args with "$@": Arg #1 = one Arg #2 = two Arg #3 = three Arg list seen as separate words. Listing args with $* (unquoted): Arg #1 = one Arg #2 = two Arg #3 = three Arg list seen as separate words.