manpagez: man pages & more
info coreutils
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4 od: Write files in octal or other formats

od writes an unambiguous representation of each file (‘-’ means standard input), or standard input if none are given. Synopses:

od [option]… [file]…
od [-abcdfilosx]… [file] [[+]offset[.][b]]
od [option]… --traditional [file] [[+]offset[.][b] [[+]label[.][b]]]

Each line of output consists of the offset in the input, followed by groups of data from the file. By default, od prints the offset in octal, and each group of file data is a C short int's worth of input printed as a single octal number.

If offset is given, it specifies how many input bytes to skip before formatting and writing. By default, it is interpreted as an octal number, but the optional trailing decimal point causes it to be interpreted as decimal. If no decimal is specified and the offset begins with ‘0x’ or ‘0X’ it is interpreted as a hexadecimal number. If there is a trailing ‘b’, the number of bytes skipped will be offset multiplied by 512.

If a command is of both the first and second forms, the second form is assumed if the last operand begins with ‘+’ or (if there are two operands) a digit. For example, in ‘od foo 10’ and ‘od +10’ the ‘10’ is an offset, whereas in ‘od 10’ the ‘10’ is a file name.

The program accepts the following options. Also see Common options.

-A radix

Select the base in which file offsets are printed. radix can be one of the following:








none (do not print offsets).

The default is octal.

-j bytes

Skip bytes input bytes before formatting and writing. If bytes begins with ‘0x’ or ‘0X’, it is interpreted in hexadecimal; otherwise, if it begins with ‘0’, in octal; otherwise, in decimal. Appending ‘b’ multiplies bytes by 512, ‘kB’ by 1000, ‘K’ by 1024, ‘MB’ by 1000*1000, ‘M’ by 1024*1024, ‘GB’ by 1000*1000*1000, ‘GB’ by 1024*1024*1024, and so on for ‘T’, ‘P’, ‘E’, ‘Z’, and ‘Y’.

-N bytes

Output at most bytes bytes of the input. Prefixes and suffixes on bytes are interpreted as for the ‘-j’ option.

-S bytes

Instead of the normal output, output only string constants: at least bytes consecutive ASCII graphic characters, followed by a null (zero) byte. Prefixes and suffixes on bytes are interpreted as for the ‘-j’ option.

If n is omitted with ‘--strings’, the default is 3.

-t type

Select the format in which to output the file data. type is a string of one or more of the below type indicator characters. If you include more than one type indicator character in a single type string, or use this option more than once, od writes one copy of each output line using each of the data types that you specified, in the order that you specified.

Adding a trailing “z” to any type specification appends a display of the ASCII character representation of the printable characters to the output line generated by the type specification.


named character, ignoring high-order bit


ASCII character or backslash escape,


signed decimal


floating point




unsigned decimal



The type a outputs things like ‘sp’ for space, ‘nl’ for newline, and ‘nul’ for a null (zero) byte. Only the least significant seven bits of each byte is used; the high-order bit is ignored. Type c outputs ‘ ’, ‘\n’, and \0, respectively.

Except for types ‘a’ and ‘c’, you can specify the number of bytes to use in interpreting each number in the given data type by following the type indicator character with a decimal integer. Alternately, you can specify the size of one of the C compiler's built-in data types by following the type indicator character with one of the following characters. For integers (‘d’, ‘o’, ‘u’, ‘x’):









For floating point (f):






long double


Output consecutive lines that are identical. By default, when two or more consecutive output lines would be identical, od outputs only the first line, and puts just an asterisk on the following line to indicate the elision.


Dump n input bytes per output line. This must be a multiple of the least common multiple of the sizes associated with the specified output types.

If this option is not given at all, the default is 16. If n is omitted, the default is 32.

The next several options are shorthands for format specifications. GNU od accepts any combination of shorthands and format specification options. These options accumulate.


Output as named characters. Equivalent to ‘-t a’.


Output as octal bytes. Equivalent to ‘-t o1’.


Output as ASCII characters or backslash escapes. Equivalent to ‘-t c’.


Output as unsigned decimal two-byte units. Equivalent to ‘-t u2’.


Output as floats. Equivalent to ‘-t fF’.


Output as decimal ints. Equivalent to ‘-t dI’.


Output as decimal long ints. Equivalent to ‘-t dL’.


Output as octal two-byte units. Equivalent to ‘-t o2’.


Output as decimal two-byte units. Equivalent to ‘-t d2’.


Output as hexadecimal two-byte units. Equivalent to ‘-t x2’.


Recognize the non-option label argument that traditional od accepted. The following syntax:

od --traditional [file] [[+]offset[.][b] [[+]label[.][b]]]

can be used to specify at most one file and optional arguments specifying an offset and a pseudo-start address, label. The label argument is interpreted just like offset, but it specifies an initial pseudo-address. The pseudo-addresses are displayed in parentheses following any normal address.

An exit status of zero indicates success, and a nonzero value indicates failure.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© 2000-2019
Individual documents may contain additional copyright information.