technovelty

weblog of Ian Wienand

RSS  |  technovelty home  |  page of ian  |  ian@wienand.org

hexdump format strings

More from the "things you'd learn if you read the manual" department, although the manual as currently written is a little esoteric on this feature of hexdump.

$ hexdump -e ' [iterations]/[byte_count] "[format string]" '

As you might guess, this means apply format string to groups of byte_count bytes, iterations times. Format string is like printf.

You can of course chain multiple formats together, or put them in a file. So say you needed to clag some binary data into a C array, a-la firmware for loading into a driver. You could use

$ hexdump -v -e '6/4 "0x%08x, "' -e '"\n"' ./dump

to get something that fits in 80 columns and is almost ready to go.

posted at: Tue, 13 Dec 2005 15:46 | in /linux/tips | permalink | add comment (2 others)

Posted by Daniel at Thu Aug 16 09:10:09 2007

Thanks a million. Please find some way to get your explanation in the hexdump man page. As of this writing, it does not adequately explain the -e option. Argh.

Posted by Andreas at Wed Mar 4 04:27:08 2009

I agree wholeheartedly with Daniel: please get this into the hexdump man page.

was wondering how to make hexdump -v -e '1/1 "\\\x"' -e '1/1 "%01x"'

=)

Add a comment
*Name
*Email (not shown)
Website
*Comment:
Anti-spam:
* denotes required field

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.