我正在尝试用1个shell脚本创建多个目录和随机文件(空)。 到目前为止,我有这个shell脚本:
#!/bin/bash
# creating dirs and files
mkdir /home/firro/opdrachta_1
我在网上搜索过脚本但找不到任何内容。
我希望有人能够帮助我。
答案 0 :(得分:1)
试试这个:
#!/bin/bash
for i in {1..10} ; do
d=$RANDOM
mkdir $d
for j in {1..5} ; do
e=$RANDOM
echo Making $d/$e
touch $d/$e
done
done
它生成10个随机目录,每个目录中包含5个随机文件。
<强>输出强>
Making 4708/295
Making 4708/9380
Making 4708/3763
Making 4708/30786
Making 4708/29234
Making 17143/15029
Making 17143/21649
Making 17143/29789
Making 17143/19491
Making 17143/21911
Making 23298/9658
Making 23298/19967
Making 23298/30776
Making 23298/13856
Making 23298/18724
Making 30923/12215
Making 30923/31772
Making 30923/10526
Making 30923/16091
Making 30923/25009
Making 9301/19563
Making 9301/17151
Making 9301/14391
Making 9301/18858
Making 9301/22637
Making 16821/20881
Making 16821/17792
Making 16821/15678
Making 16821/24846
Making 16821/12214
Making 28562/1936
Making 28562/4960
Making 28562/9094
Making 28562/3707
Making 28562/29765
Making 30897/12237
Making 30897/17669
Making 30897/8653
Making 30897/27358
Making 30897/8184
Making 2095/31555
Making 2095/8335
Making 2095/20117
Making 2095/27136
Making 2095/14663
Making 4827/22412
Making 4827/17678
Making 4827/5273
Making 4827/4538
Making 4827/12831