0

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.

2
  • e.g. my file want to have the format: 1234567890.....555 Commented May 16, 2015 at 9:22
  • 1
    peterh's answer is correct. You can only copy files or, more generally, streams of data with dd, typically from or to a block oriented device. That said, you are also unclear about the desired format. Is it binary (i.e. the bytes in your target file are 0x01, 0x02, 0x03... or is it a binary representation of 4 byte integers, like 0x00, 0x00, 0x00, 0x01 (first int), 0x00, 0x00, 0x00, 0x02 (2nd int) etc.? (And then, which byte order?) Or is it an ascii representation, i.e. 0x31, 0x32, 0x33... (i.e. '1', '2', '3')? Commented May 16, 2015 at 9:34

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.