What is xxd?
How does ckormanyos/xxd differ from Vim's bundled xxd?
Is xxd already installed on my system?
When I want to color my program's output, I just use color escape such as printf("\033[1;93m Colored Stuff\n"). But, when I pipe my program (colored) output to a text file, the escape sequence is visible. For example:
suppose I have a program called hello that calls printf("\033[1;93mHELLO WORLD!\n"), and I do:
hello > output.bin
the actual output is "\033[1;93mHELLO WORLD!" instead of "HELLO WORLD!".
but when I do:
xxd my_bin_file.bin > output.txt
the output.txt file contains all content, except color escapes.
I looked at the xxd source code but I didn't find anything about it.
And yes, all this stuff for print colored stuff lol.
There's no one command that I know of that will do the conversion, but it can easily be broken up into a few steps:
- Strip addresses from
hexdumpoutput usingsed - Convert into binary using
xxd - Endian conversion (for example,
5a42becomes425a) usingdd
Here's the full command:
sed 's/^[0-9]*//' hexdump | xxd -r -p | dd conv=swab of=binaryfile
Try to add -p.
xxd -r -p hexdumpfile > binaryfile
