linux $* 和$@例子
参见ibm网站示例:
https://www.ibm.com/developerworks/cn/linux/l-bash-parameters.html
示例:
[ian@pinguino ~]$ type testfunc2 testfunc2 is a function testfunc2 () { echo "$# parameters"; echo Using '$*'; for p in $*; do echo "[$p]"; done; echo Using '"$*"'; for p in "$*"; do echo "[$p]"; done; echo Using '$@'; for p in $@; do echo "[$p]"; done; echo Using '"$@"'; for p in "$@"; do echo "[$p]"; done }
执行如下:
[ian@pinguino ~]$ IFS="|${IFS}" testfunc2 abc "a bc" "1 2 > 3" 3 parameters Using $* [abc] [a] [bc] [1] [2] [3] Using "$*" [abc|a bc|1 2 3] Using $@ [abc] [a] [bc] [1] [2] [3] Using "$@" [abc] [a bc] [1 2 3]