Hello ALUG list,
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}
but it just said that my format string was a "bad format {%x}".
Any help would be very much appreciated!
Richard.
On Wed, May 21, 2003 at 11:50:27PM +0100, richard wrote:
Hello ALUG list,
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).
This *may* do something akin to what you're looking for:
perl -e 'while(read(STDIN,$i,1)){printf("%x",ord($i))}' < infile > outfile
I would check that the output is correct though.
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}
but it just said that my format string was a "bad format {%x}".
Any help would be very much appreciated!
Richard.
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
On Wednesday 21 May 2003 11:50 pm, richard wrote:
Hello ALUG list,
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}
but it just said that my format string was a "bad format {%x}".
Any help would be very much appreciated!
Why not just look at it in one of the hex editors?
Ian
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
richard richard.lewis@uea.ac.uk wrote:
Hello ALUG list,
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}
but it just said that my format string was a "bad format {%x}".
OK - having just played with it for the last 5 mins to see what I could find out... I've got the following...
hexdump -e '16/1 "%02x" "\n"' filename
16/1 means take sixteen single byte values per line... and %02x means format them as 0 padded 2 digit hex format output
(so, 32 chars wide, then :)
Everyone else seems to have suggested perl, *SIGH* why not use the tool thats designed for the job <G>
Cheers,
Brett