AnkurTank AnkurTank - 1 year ago 62
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?

Answer Source

You could use process substitution:

dd if=<(yes foo) of=foo_200kb bs=1024 count=200
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download