richard richard.lewis@uea.ac.uk writes:
Does anyone know to use the hexdump program?
I've been trying all night (and am at serious risk of fatal caffeine poisoning!)
All I want it to do is print every byte of a file in hex notation without any other rubbish (no indexes, no ASCII, no spaces, no line feeds, no nothing).
It claims that you can pass it a format string in the same format as fprintf() so I tried this: $ hexdump -e "%x" {filename} >{outputfile}
In fact, it says:
The format is required and must be surrounded by double quote (" ") marks. It is interpreted as a fprintf-style format string (see fprintf(3)), with the following exceptions:
The quotes you typed are removed by the shell and must be escaped if they are to be passed to the hexdump program itself, e.g.:
hexdump -e "%x" /path/to/your/file
I've no idea why it requires the quotes at all...
However I don't think hexdump can easily be pressed into service for what you want to do. I'd use:
perl -pe 's/./sprintf("%x",ord($&))/sge' FILENAME