How do I get an equivalent of /dev/one in Linux

bash, file, linux

Solution

Try this:

dd if=<(yes $'\01' | tr -d "\n") of=file count=1024 bs=1024

Substitute `$'\377'` or `$'\xFF'` if you want all the bits to be ones.

MacOS `tr` may complain about "Illegal byte sequence". Setting `LC_CTYPE=C` will prevent that. This version can also be used in Linux:

dd if=<(yes $'\01' | LC_CTYPE=C tr -d "\n") of=file count=1024 bs=1024

Problem

You can use ``` dd if=/dev/zero of=file count=1024 bs=1024 ``` to zero fill a file. Instead of that I want to one fill a file. How do I do that? There is no `/dev/one` file, so how can I simulate that effect via on bash shell?

Original source

Related problems