1

What's the quickest way to write a sequence of bytes from the commandline into a file? For example consider an input string in the following format:

DE AD BE EF

How can I write this to a file, so that the output file consists exactly of these 4 bytes? Of course I could write a python script to do it, but maybe there is a quick way directly over the command line?

1

1 Answer 1

3
$ echo -en '\xde\xad\xbe\xef' | hexdump -C
00000000  de ad be ef                                       |....|
00000004
$

Replace | hexdump -C with > path/to/file to write to a file (or >> to append to a file).

If you have a file of a sequence, you can do this to "convert" it:

$ cat test
DE AD BE EF
DE AD BE EF
$ for i in $(cat test); do echo -en "\x$i"; done | hexdump -C
00000000  de ad be ef de ad be ef                           |........|
00000008
$
1
  • This not writing to a file as the asker requests. He may not know how to modify your commands.
    – DavidPostill
    Commented Oct 23, 2019 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .