1. 程式人生 > >bash shell中利用迴圈建立多個檔案

bash shell中利用迴圈建立多個檔案

1.用while迴圈

命令:

i=1; while [ $i -le 99 ]; do name=`printf "test%02d.txt"  $i`; touch "$name"; i=$(($i+1)); done

2.用for迴圈和seq命令

命令:

for i in $(seq 99); do name=$(printf test%02d.txt $i); touch "$name"; done

以上兩個命令都將生成test01.txt到test99.txt共99個檔案