Od

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Od is a Unix command-line tool used to show the raw bytes of a file in various ways including hexadecimal and octal, available on many platforms.

Options[edit]

Command-line options aka switches of od:

  • -b: Show bytes in octal.
  • -c: Show the ASCII characters of bytes.
  • -d: Show words in decimal.
  • -o: Show words in octal.
  • -x: Show words in hex.

Command-line options aka switches of GNU od, beyond the bare-bones od:

  • -t: Display the bytes as per format string.
  • And more.

Links:

Examples[edit]

Examples of od use:

  • od -x myfile
    • Outputs hex, interpreting per two bytes.
  • od -tx1 myfile
    • In GNU od, outputs hex, interpreting per one byte. Depending on the endianness of the system, the sequence on the byte level need not be the same as with od -x.
  • od -tx1z myfile
    • In GNU od, as above but outputting ASCII to the right per "z".
  • od -txz myfile
    • In GNU od, as above, but interpreting per multiple bytes.
  • od -tx8z myfile
    • In GNU od, as above but interpreting per 8 bytes.
  • od -tx7z myfile
    • In GNU od, may return with an error, since 7 is not a byte count supported.
  • od -tx16z myfile
    • In GNU od, may return with an error, since 16 is not a byte count supported.

Versions[edit]

A version of GNU od for MS Windows is available from GnuWin32 project, as well as from Cygwin.

External links[edit]