Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fduran/f678b4b67f559ad505d8 to your computer and use it in GitHub Desktop.
Save fduran/f678b4b67f559ad505d8 to your computer and use it in GitHub Desktop.
Linux Bash generate a number of files of random sizes in a range
#!/bin/bash
# generate a number of files with random sizes in a range
min=1 # min size (MB)
max=10 # max size (MB)
nofiles=20 # number of files
for i in `eval echo {1..$nofiles}`
do
dd bs=1M count=$(($RANDOM%max + $min)) if=/dev/urandom of=./files/file$i
done
@laszlolaszlo
Copy link

laszlolaszlo commented Dec 8, 2023

I think you have to change bs and count like this:
dd bs=$(($RANDOM%max + $min))M count=1 if=/dev/urandom of=./files/file$i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment