1 #! /bin/bash 2 test() { 3 echo "未加引号,二者相同" 4 echo $* 5 echo [email protected] 6 echo "加入引号后对比" 7 for N in "$*" 8 do 9 echo $N 10 done 11 12 echo "----------" 13 for N in "[email protected]" 14 do 15 echo $N 16 done 17 } 18 test 12 123 3424 546
可以看到不加引号时,二者都是返回传入的参数,但加了引号后,此时$*把参数作为一个字符串整体(单字符串)返回,[email protected]把每个参数作为一个字符串返回
原文地址:https://www.cnblogs.com/tele-share/p/9080069.html
时间: 2024-10-08 17:26:10