I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data.
Name size file1.01 2K file2.02 3K file3.03 5K etc.
How can I create many files like this?
A variation with
seq -w 1 10 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=$(shuf -i1-10 -n1) count=1024'
Explanation as requested per comments:
seq -w 1 10 prints a sequence of numbers from 01 to 10
xargs -n1 -I% executes the command
sh -c 'dd ... % ...' for each sequence number replacing the % with it
dd if=/dev/urandom of=file.% bs=$(shuf ...) count=1024 creates the files feeded from /dev/urandom with 1024 blocks with a blocksize of
shuf -i1-10 -n1 a random value from 1 to 10
This uses a single pipeline and seems fairly fast, but has the limitation that all of the files are the same size
dd if=/dev/urandom bs=1024 count=10240 | split -a 4 -b 1k - file.
Explanation: Use dd to create 10240*1024 bytes of data; split that into 10240 separate files of 1k each (names will run from 'file.aaaa' through 'file.zzzz')