Alpha Grisby Alpha Grisby - 4 months ago 58
Bash Question

Shell : "touch" command

I have the following shell command, allowing to create blank files with randoms Last Modification Times.

for i in {1..10}; do touch -d "$(((RANDOM % 36) + 1980))-$(((RANDOM % 11)+1))
-$(((RANDOM % 28)+1)) 12:12:12.000000000 +0530" file$i;done

I'd like to make those files occupy a certain amount of bytes (which I would randomly generate). Is it possible somehow with touch, or do I need something completely different ? Thanks in advance.


Just add the following in the loop after touch command:

dd if=/dev/zero of=file$i bs=1 count=10

where 10 is the number of bytes.