Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Last active July 23, 2020 19:11
Show Gist options
  • Save jstaursky/16685100ed5f35292366edc68d19212f to your computer and use it in GitHub Desktop.
Save jstaursky/16685100ed5f35292366edc68d19212f to your computer and use it in GitHub Desktop.
hexdump vs od

Equivalent expressions in od and hexdump

interpret next 4 bytes as a signed decimal

od -t d4

format the next 4 bytes as a 4 byte decimal

hexdump  -e '/4 " %d"'

Benefits to od

  • Can specify endianess --endian=big|little
  • Formatting is more intuitive; just -t [TYPE][SIZE] for TYPE in [doux] (i.e. decimal, octal, unsigned, hex). SIZE is number of bytes that are considered apart of TYPE’s interpretation of the input (e.g. is 0x01,0x10 two 1 byte integers or 1 two byte integer?).

Benefits to hexdump

  • More control of input, output format. The first number of the ‘n/m “%fmt”’ string is the number of elements/iterations to process for elements of byte length “m”. You are also not restricted to only puting format characters in the “” string but can add characters to be written alongside the formatted output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment