To create a binary file with all '0's, one could do

dd if=/dev/zero of=foo bs=1024 count=1

What if I wanted to create a file with all '1's? I can't find /dev/one anywhere.


There is no such virtual device as /dev/one. You can replace the NUL character that you receive from /dev/zero though:

dd if=/dev/zero bs=1024 count=1 | tr '\000' '1' > foo

Replace '1' with whatever you need instead. The '1' will result in hexadecimal 31, so the "standard" 1, which could also be written as octal \061. You can use octal notation in tr by prepending with \, like with \000.


If you wish to create a file with binary 1s the following will work:

dd if=/dev/zero bs=1 count=1024 | tr "\000" "\377" > foo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.