我想在当前目录下生成,ar_$i和full_$i文件各10个.
刚开始写的脚本如下:
-------------------------------------
for((i=1;i++;i<=10)) --这种格式是调用c的编程方式,
do
touch ar_$i;
touch full_$i;
done;
执行的结果根本不是我想要的.
man bash查到for语句的help
-------------------------------------
for (( expr1 ; expr2 ; expr3 )) ; do list ; done
First, the arithmetic expression expr1 is evaluated according to the rules described below under
ARITHMETIC EVALUATION. The arithmetic expression expr2 is then evaluated repeatedly until it
evaluates to zero. Each time expr2 evaluates to a non-zero value, list is executed and the arith
metic expression expr3 is evaluated. If any expression is omitted, it behaves as if it evaluates
to 1. The return value is the exit status of the last command in list that is executed, or false
if any of the expressions is invalid.
后来在请教ark后,把脚本修改成如下:
----------------------------------------------------
for((i=1;i<=10;i=i+1))
do
touch ar_$i;
touch full_$i;
done;
阅读(1928) | 评论(0) | 转发(0) |