On Unix-like operating systems, the od command dumps the contents of files to octal, and other formats.

This page describes the GNU/Linux version of od.

Description

The od command writes an unambiguous representation, using octal bytes by default, of FILE to standard output. If more than one FILE is specified, od concatenates them in the listed order to form the input. With no FILE, or when FILE is a dash ("-"), od reads from standard input.

  • Description
  • Syntax
  • Format specifications
  • Examples
  • Linux commands help

Syntax

od [OPTION]… [FILE]…

od [-abcdfilosx]… [FILE] [[+]OFFSET[.][b]]

od –traditional [OPTION]… [FILE] [[+]OFFSET[.][b] [+][LABEL][.][b]]

Options

Format specifications

If first and second call formats both apply, the second format is assumed if the last operand begins with “+” or (if there are 2 operands) a digit. An OFFSET operand means -j OFFSET. LABEL is the pseudo-address at first byte printed, incremented when dump is progressing. For OFFSET and LABEL, a 0x or 0X prefix indicates hexadecimal; suffixes may be “.” for octal and b for multiply by 512.

All arguments to –long options are mandatory for -short options.

TYPE is made up of one or more of these specifications:

SIZE is a number. For TYPE in d/o/u/x, SIZE may also be C for sizeof(char), S for sizeof(short), I for sizeof(int) or L for sizeof(long). If TYPE is f, SIZE may also be F for sizeof(float), D for sizeof(double) or L for sizeof(long double).

RADIX is d for decimal, o for octal, x for hexadecimal or n for none. BYTES is hexadecimal with 0x or 0X prefix, and may have a multiplier suffix: b 512, kB 1000, K 1024, MB 10001000, M 10241024, GB 100010001000, G 102410241024, and so on for T, P, E, Z, Y. Adding a z suffix to any type displays printable characters at the end of each output line. Option –string without a number implies 3; option –width without a number implies 32. By default, od uses -A o -t oS -w16.

Examples

od -b file.txt

Display the contents of file.txt in octal format (one byte per integer).

od -Ax -c file.txt

Display the contents of file.txt in ASCII (character) format, with byte offsets displayed as hexadecimal.