while循环无法批量建立文件,求指教shell脚本

我用while循环要建立10个文件,注释那种,但是写好了后只有1个文件,不知道哪里出错了

sh -x yourshell
去看每行执行

[root@iZ259r7h4pfZ ~]# sh 1
[root@iZ259r7h4pfZ ~]# ls /root/ABC/
aalcsbiwul_ABC.html dfyomkfmcj_ABC.html jyynyzwjqt_ABC.html tokioccene_ABC.html
awakabawze_ABC.html gawfmdhyuj_ABC.html lybdnysmqh_ABC.html
crzoqaowmn_ABC.html getmrxowvj_ABC.html qlgxlqihrr_ABC.html
[root@iZ259r7h4pfZ ~]# cat 1
[ -d /root/ABC ] || mkdir /root/ABC &> /dev/null
i=1
while [ $i -le 10 ];
do
A=`openssl rand -base64 40|sed 's#[^a-z]##g'|cut -c 1-10`
touch /root/ABC/${A}_ABC.html
let i++
done

你应该把A的赋值,放在循环里,否则touch 10个一样的文件
温馨提示:答案为网友推荐,仅供参考
相似回答