rename

rename abc abc0 *abc*

会把当前文件夹下匹配到*abc*的文件中的第一个abc替换为abc0

 

二次变量名,二次访问count变量直接读出$0 $1 $2等

1 #!/bin/bash
2 
3 typeset param_num=$#
4 typeset count=0
5 while((count<=param_num))
6 do
7     echo ${!count}
8     ((++count))
9 done

另一种方法,利用eval

 1 #!/bin/bash
 2 
 3 typeset param_num=$#
 4 typeset count=0
 5 while((count<=param_num))
 6 do
 7     #echo ${!count}
 8     eval echo \$$count
 9     ((++count))
10 done

 

 

#!/bin/bash

fname=${1:-hello}
echo $fname

$1为空则fname为hello,否则fname为$1

 

posted on 2012-07-26 14:14  吃吃户  阅读(309)  评论(0编辑  收藏  举报