1

How do you write specific bytes to a file?

view story
linux-howto

http://unix.stackexchange.com – Given a file myfile with the following contents: $ cat myfile foos A hexdump of the file gives us the contents: $ hexdump myfile 6f66 736f 000a Currently, I can create the file by specifying the contents in ascii like this: $ echo foo > myfile Is it possible to create the file by giving it the exact bytes in hexadecimal rather than ascii? $ # How can I make this work? $ echo --fake-hex-option "6f66 736f 000a" > myfile $ cat myfile foos Update: For clarity's sake, I worded the question to ask how to write a small number of bytes to a file. In reality, I need a way to pipe a la (HowTos)