[英]How can I generate random files with size 1mb each from 1-500 using linux shell script
How can I generate random files with size 1mb each from 1-500 using linux shell script. 如何使用Linux Shell脚本从1-500生成大小为1mb的随机文件。
I wanted to create 100 random files in 500 directory locations but I am not able to create random files. 我想在500个目录位置中创建100个随机文件,但无法创建随机文件。 1 file with 500 directory is working with below command in shell script:
1个500目录的文件正在Shell脚本中使用以下命令:
for i in {001..500};
do
for j in {001..001};
do dd if=/dev/urandom
of=/home/h2h/pickup/AGENT_CH_${j}/AG_${j}_File${i}.csv bs=1M count=1;
done
done
My directory locations as in format : 我的目录位置格式如下:
/home/h2h/pickup/AGENT_CH_001/
/home/h2h/pickup/AGENT_CH_002/
It' working fine to create 1 file each with 500 directories. 可以创建一个每个文件包含500个目录,这很好。 Now I am trying to generate 10 files for any random 100 directories.
现在,我尝试为任意100个目录生成10个文件。
Can someone please help on this? 有人可以帮忙吗?
If I understand correctly, you need to have 100 random files in each 500 directories. 如果我理解正确,则每500个目录中需要有100个随机文件。
If so, try this: 如果是这样,请尝试以下操作:
for d in {001..500}; do
for f in {001..100}; do
dir="/home/h2h/pickup/AGENT_CH_${d}"
[ -d "$dir" ] || mkdir -p "{dir}"
dd if=/dev/urandom of="${dir}/AG_${d}_File${f}.csv" bs=1M count=1
done
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.