creating random amount of directory’s with random files in it
Posted on June 15, 2016 • 1 minutes • 115 words • Suggest Changes
One of the reasons I love Linux is the fact you can combine a few commands and do the most boring jobs in seconds, way better then manual work could have; An example ? I wanted to have a “random” file structure with not empty files. (so files with content) So I created 100 directory’s and added 10 files to each directory with random content and increasing size. Sounds like allot of work right ?
for a in {1..100}; do mkdir dir$a/; cd dir$a; for i in {1..10}; do dd if=/dev/urandom of=file_$i.log bs=1M count=$i; done; cd ..; done
Bam ! Although full disclaimer, bash should take the credit here ! Thx bash <3 <3 <3