Format
od [–v]
[–A addr_fmt]
[–j num [bkm]]
[–N num] [–T]
[–t type_string]
[file … ]
od [–bcDdhOoSsTvXx]
[file] [[+]offset[.][b]]
Description
od (octal
dump) dumps a file to the standard output in a format specified by
command-line options. The default format is octal words. You can use
combinations of options to generate multiple formats with the requested
representation of each byte vertically aligned. The file seek address
(in octal) precedes each line of new data.
od recognizes
two syntaxes. The first one conforms to POSIX. If you choose the first
form, od displays files from the list file one
at a time. If no file appears on the command
line, od reads the standard input.
For
a summary of the UNIX03 changes to this command, see Shell commands changed for UNIX03.
Options
The first form of
od accepts
the following options:
- –v
- Displays all lines. Typically, od does
not display multiple lines that differ only in the address. It displays
the first line with a single * under it. to show
that any subsequent lines are the same.
- –A addr_fmt
- Specifies the format that od uses to
display the address field. addr_fmt can
be d (decimal), o (octal), x (hexadecimal),
or n (do not display address). The default
is –A o.
- –j num
- Skips num bytes from the beginning of
the file. If you precede num with 0X or 0x, od interprets
it as hexadecimal. If you precede it with 0, od interprets
it as octal; otherwise, od assumes that
it is decimal. You can also append b, k,
or m to num to
indicate 512-byte blocks, kilobytes, or megabytes instead of bytes.
If num is hexadecimal, any appended b is
considered to be the final hexadecimal digit rather than 512-byte
block.
Be careful with this option when working with double-byte
characters. If byte num+1 (the starting
byte, after skipping num bytes) is not the
first byte of a character, od proceeds as
though it is, resulting in a misinterpretation of that and subsequent
characters. This misinterpretation continues until od encounters
a <newline>. Then it is once again synchronized with the first
byte of a double-byte character.
- –N num
- Processes a maximum of num bytes. Be
careful with this option when working with double-byte characters.
If od is processing a double-byte character
when it encounters the numth byte and this
byte is not the last byte of the character, od displays ??? instead
of the character.
–T 
Enables automatic conversion for tagged files. This option is
mutually exclusive with –t a. For more information
about automatic
conversion and file tagging, see z/OS UNIX System Services Planning.
- –t type_string
- Specifies the output format. type_string can
contain the following format characters:
- a
- Named characters from the ISO 646 character set. Data is interpreted
as if it was coded in the ISO 646 character set.
- c
- Characters. od displays nonprintable
characters as backslash sequences and displays printable double-byte
characters properly.
A printable double-byte character is displayed
in the first byte position, and the remaining positions to the end
of the character display ** to indicate the double-byte character.
Nonprintable double-byte characters are displayed using a 3-digit
octal number to represent each byte.
Also, incorrect double-byte
sequences are displayed with ??? for each incorrect
byte.
- d
- Signed decimal. A one-digit number may follow d telling od how
many bytes to use. This must correspond to the size of a char (1-byte
character), a short (2 byte short), an int (4
byte integer), a long (4 bytes long, which
is currently the same as integer on z/OS), or
a long long (8 byte integer). The default
size is the size of an int. A symbolic
size character can follow d, rather than
the number of bytes. These have the following meaning:
- C
- Corresponds to number of bytes in a char
- S
- Corresponds to number of bytes in a short int
- I
- Corresponds to the number of bytes in an int
- L
- Corresponds to the number of bytes in a long int
- LL
- Corresponds to the number of bytes in a long long
int
- f
- Hexadecimal floating-point. A one-digit number can follow f,
telling od how many bytes to use. This must
correspond to the size of a float, double,
or long double. The default size is the
size of a double. A symbolic size character
can follow f, rather than the number of
bytes. These have the following meaning:
- F
- Corresponds to size of float
- D
- Corresponds to size of double
- L
- Corresponds to size of long double
- F
- IEEE binary floating-point. A one-digit number can follow F,
telling od how many bytes to use. This must
correspond to the size of a float, double,
or long double. The default size is the
size of a double. A symbolic size character
can follow F, rather than the number of
bytes. These have the following meaning:
- F
- Corresponds to size of float
- D
- Corresponds to size of double
- L
- Corresponds to size of long double
- o
- Octal. A one-digit number can follow o,
telling od how many bytes to use. This must
correspond to the size of a char (1 byte
character), a short (2 byte short), an int (4
byte integer), a long (4 byte long, which
is currently the same as integer on z/OS), or
a long long (8 byte integer). The default
size is the size of an int. A symbolic size
character can follow o, rather than the
number of bytes. These have the following meaning:
- C
- Corresponds to number of bytes in a char
- S
- Corresponds to number of bytes in a short int
- I
- Corresponds to the number of bytes in an int
- L
- Corresponds to the number of bytes in a long int
- LL
- Corresponds to the number of bytes in a long long
int
- u
- Unsigned decimal. A one-digit number can follow u,
telling od how many bytes to use. This must
correspond to the size of a char (1 byte
character), a short (2 byte short), an int (4
byte integer), a long (4 byte long, which
is currently the same as integer on z/OS), or
a long long (8 byte integer). The default
size is the size of an int. A symbolic size
character can follow u, rather than the
number of bytes. These have the following meaning:
- C
- Corresponds to number of bytes in a char
- S
- Corresponds to number of bytes in a short int
- I
- Corresponds to the number of bytes in an int
- L
- Corresponds to the number of bytes in a long int
- LL
- Corresponds to the number of bytes in a long long
int
- x
- Hexadecimal. A one-digit number can follow x,
telling od how many bytes to use. This must
correspond to the size of a char (1 byte
character), a short (2 byte short), an int (4
byte integer), a long (4 byte long, which
is currently the same as integer on z/OS), or
a long long (8 byte integer). The default
size is the size of an int. A symbolic
size character can follow x, rather than
the number of bytes. These have the following meaning:
- C
- Corresponds to number of bytes in a char
- S
- Corresponds to number of bytes in a short int
- I
- Corresponds to the number of bytes in an int
- L
- Corresponds to the number of bytes in a long int
- LL
- Corresponds to the number of bytes in a long long
int
Multiple
format characters can appear in one type_string and
multiple –t options can appear on the command
line. If there is no –t option, the default
is –t oS.
Restriction: –t
a is mutually exclusive with the –T option.
The second form of od is
the historical (Berkeley Software Distribution) implementation of
the command. If you use this form, you can specify only a single input file.
If you do not give a file argument, od reads
the standard input. You can supply an offset, but you must precede
it with a plus sign (+) to distinguish it from a
file name if no file is given. Giving an offset causes a seek to a
position in the file where output begins. If the offset ends in a
period (.), od considers
it to be decimal; otherwise, od considers
it octal. If you follow the offset with a b, od multiplies
it by the block size of 512 bytes. The format of the offset determines
the format of the address; that is, if it is interpreted as decimal,
the addresses are displayed in decimal.
Restriction: The od command
does not work on a file whose file name starts with either a digit
or a plus (+) sign, unless the –A, –N, –j,
or –t options are used.
Localization
od uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- LC_NUMERIC
- LC_SYNTAX
- NLSPATH
See Localization for more
information.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Inability to open the input file
- Badly formed offset
- Seek or read error on the input file
- 2
- Failure due to any of the following:
- Incorrect command-line argument
- The wrong number of command-line arguments
- Incorrect format character
- Incorrect size modifier for format character
Portability
POSIX.2, X/Open Portability Guide, UNIX systems.
The
options to operate on longs (–OSXD) and
the hexadecimal byte (–h) are extensions
to the POSIX standard.
The –T option is an extension to the POSIX standard.