脚本的$@和$*"/>
shell脚本的$@和$*
@ 和 @和 @和*的区别
#!/bin/bash# $@ and $* my_fun (){echo "$#"}echo 'the number of parameter in "$@" is' $(my_fun "$@")
echo 'the number of parameter in "$*" is' $(my_fun "$*")echo 'the number of parameter in $@ is' $(my_fun $@)
echo 'the number of parameter in $* is' $(my_fun $*)
[lf@x201t ~]$ sh a.sh p1 "p2 p3" p4the number of parameter in "$@" is 3
the number of parameter in "$*" is 1the number of parameter in $@ is 4
the number of parameter in $* is 4
看出区别了吗?关键 $@ 靠谱一点
更多推荐
shell脚本的$@和$*
发布评论