在shell脚本当中会经常使用到参数和变量 常量
有一种很好用的方式
shell> set "1 2 3 4 5 6" #设置位置参数 $1 shell> for i in $* >do echo $i >done shell>shift #清除位置参数 一旦执行shift $1的初始值会永远消失,取而代之的是$2d的旧值 $2的值变为$3的旧值 以此类推 shell>for i in $*;do echo $i;done shell> #什么也没有 shell> set 123 234 345 456 567 shell> echo $# shell>5 #5个位置参数 shell> for i in $*;do echo $i;done shell>123 shell>234 shell>345 shell>456 shell>567 shell> shift #去除第一个位置参数 shell>echo $# 还剩4个位置参数 shell>4 shell> for i in $*;do echo $i;done #第一个位置参数已经被去掉 shell>234 shell>345 shell>456 shell>567
请尊重知识,请尊重原创 更多资料参考请见 http://www.cezuwang.com/listFilm?page=1&areaId=906&filmTypeId=1