shell脚本中的$*,$@和$#
2013-12-26 13:47
183 查看
#!/bin/bash my_fun() { echo "$#" } echo 'the number of parameter in "$@" is '$(my_fun "$@") echo 'the number of parameter in "$*" is '$(my_fun "$*") 执行:./my.sh p1 "p2 p3" p4后返回: the number of parameter in "$@" is 3 the number of parameter in "$*" is 1 $*表示所有这些参数都被双引号引住。若一个脚本接收两个参数,$*等于$1$2 $@表示所有这些参数都分别被双引号引住,若一个脚本接收到两个参数,$@等价于$1$2 $#表示提供给脚本的参数号 这里怎么看出$*和$@的区别呢?为什么执行结果是3和1呢?这里$#又是什么意思呢?脚本名称叫test.sh 入参三个: 1 2 3
运行test.sh 1 2 3后 $*为"1 2 3"(一起被引号包住) $@为"1" "2" "3"(分别被包住) $#为3(参数数量)
相关文章推荐
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中的$*,$@和$#
- shell脚本中$@与$#区别
- 一个shell脚本引发的对于分号(;)和$#的使用说明(转载)
- shell脚本中$#、$0、$@等特殊变量的含义
- shell脚本中$#、$0、$@等特殊变量的含义
- Shell脚本中$、$#、$0、$1、$2、$@的介绍及demo演示
- Shell脚本中$0、$?、$!、$$、$*、$#、$@
- shell脚本中$#、$0、$@等含义
- Shell脚本里面 $#, $@的含义
- 1、关于shell脚本里面$*,$@,$#的含义
- shell脚本中$#、$0、$@等特殊变量的含义
- shell脚本中的$*、$@、$#的区别
- shell脚本中$#、$0、$@等特殊变量的含义