AnkurTank AnkurTank - 2 months ago 5
Bash Question

How to create a fixed size file which is initialized with fixed string?

I want to create a file with fixed size which is filled with a repetition of string of my choice.

So far I have tried using

to create a file as follows:

dd if=/dev/urandom of=foo_200kb bs=1024 count=200

but obviously the file's content will be random. How can I fill the file with a string of my choice?


You could use process substitution:

dd if=<(yes foo) of=foo_200kb bs=1024 count=200