Panagiotis
Panagiotis

Reputation: 511

How can I create a file with specific values using the dd command?

How can I create a file with specific number values using command dd in linux enviroment? I want a file size 4*500 (every integer number have 4 bytes and I want 500 positions).

My file want to have the format: 1234567890.....555.

Upvotes: 0

Views: 1590

Answers (1)

peterh
peterh

Reputation: 1

Only with dd you can't do this. dd only copies a byte stream from its input to its output, it can't generate anything. You need to have same source for the dd which generates the needed data from.

The nearest which you can do that would be a simple shellscript, like this:

for i in $(seq 1 555);do echo -n $i;done

Of course, you can pipe its output into a ddas well, for example:

for i in $(seq 1 555);do echo -n $i;done|dd bs=4096 count=1

Upvotes: 2

Related Questions