This really is a trivial code snippet, but as with most scripts it comes in handy because it simplifies even a basic task further. Save this to a simple filename like ‘hex2file’ and place it in your /usr/bin directory. Whenever you need to write out hex characters directly to a file use the following syntax.
hex2file 4142434445 > hexfile.bin
hexdump -C hexfile.bin 00000000 41 42 43 44 45 |ABCDE| 00000005
Here is the snippet.
#!/usr/bin/python import sys sys.stdout.write(sys.argv.decode('hex'))
Again, trivial – but useful!