hexdump's format string is hard to use IMO, and the shipped version on Debian 6 and OS X doesn't support 64-bit integer. So I created this little tool in Go to replace hexdump for my own need.
Limitations:
- Does not support floating point number and string
- Does not have special print specifier to control where to print offset, etc.
- Others features that I do not use
In bprint, the binary data specification and how the they are going to be
printed is specified separately using the -e and -p option.
-especifies binary field. Using the same syntax as Ruby'sArray.unpack.c,s,l,qstands for signed 8,16,32,64-bit integerC,S,L,Qstands for unsigned 8,16,32,64-bit integer- A number following the type specifier repeats that specifier. For example,
c4is equivalent tocccc
-pspecifies how to print the binary data. It uses C printf style field specifier%c,%d,%x,%oare supported, size and signess information is implicit from the binary field information- if not specified, defaults to
%02xfor each binary field - field can be followed by an optional seperator and count to repeat. For example,
%2d-3#is eqivalent to%2d-%2d-%2d
-fread binary and print format from file. 1st line for binary format, 2nd line for print format (optional). Command line option overrides spec in file-oprint offset at the left most column-cprint how many record has been read (right after offset column)--versionprint version information
Suppose each record in the binary file contains 2 byte and 1 64-bit integer, here's invocation to print it's content:
bprint -e 'c2q' -p '%x %d2#' bindata