I was wondering if anybody knew of a command line utility that would allow me to directly write hex values to a file. such that when a hexdump of the file is done the values that I enter would be spit out. It is vital that I write directly to hex as many of the value that I need to write do not have any unicode or ascii equivalent characters associated with them.
Looking for something like:
writehex f6050000 ac7e0500 02000800 01000000 newfile
hexdump newfile
hexdump 1.02
ts.event.1
00000000: f6050000 ac7e0500 02000800 01000000 .....~..........
16 bytes read
Best Answer
This Bash function should work for you:
Alternative implementation:
To test it:
Another option would be to use
xxd
.Edit:
Additionally, you can use the
-p
option to accept somewhat freeform input data:Edit 2:
Modified function above to handle multiple input arguments (strings of hex digits separated by spaces).