99问答网
所有问题
while循环无法批量建立文件,求指教shell脚本
我用while循环要建立10个文件,注释那种,但是写好了后只有1个文件,不知道哪里出错了
举报该问题
推荐答案 2017-12-13
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个一样的文件
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/WXzOzjXBBt7tvOe7XeX.html
相似回答
大家正在搜
相关问题
shell脚本问题,while里面if条件判断,求大神指导
求shell脚本批量生成文件(文件内容和文件名有关)!!达人...
shell脚本while read循环无法执行命令,不用循环...
shell 里的while做循环条件 if语句做判断 的脚本...
shell脚本读取文件,文件是有多个字符串,中间是空格。这个...
shell脚本用while循环计算1-100偶数相加
shell脚本实现定时生成个以当前时间命名的TXT文件,然后...
linux shell脚本:while循环中调用另一个脚本遇...