xref: /titanic_51/usr/src/man/man1/od.1 (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
te
Copyright 1989 AT&T Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
OD 1 "May 20, 2005"
NAME
od - octal dump
SYNOPSIS

/usr/bin/od [-bcCDdFfOoSsvXx] [-] [file] [offset_string]

/usr/bin/od [-bcCDdFfOoSsvXx] [-A address_base] [-j skip]
 [-N count] [-t type_string]... [-] [file]...

/usr/xpg4/bin/od [-bcCDdFfOoSsvXx] [file] [offset_string]

/usr/xpg4/bin/od [-bcCDdFfOoSsvXx] [-A address_base]
 [-j skip] [-N count] [-t type_string]... [file]...
DESCRIPTION

The od command copies sequentially each input file to standard output and transforms the input data according to the output types specified by the -t or -bcCDdFfOoSsvXx options. If no output type is specified, the default output is as if -t o2 had been specified. Multiple types can be specified by using multiple -bcCDdFfOoSstvXx options. Output lines are written for each type specified in the order in which the types are specified. If no file is specified, the standard input is used. The [offset_string] operand is mutually exclusive from the -A, -j, -N, and -t options. For the purposes of this description, the following terms are used: word

Refers to a 16-bit unit, independent of the word size of the machine.

long word

Refers to a 32-bit unit.

double long word

Refers to a 64-bit unit.

OPTIONS

The following options are supported: -A address_base

Specifies the input offset base. The address_base option-argument must be a character. The characters d, o and x specify that the offset base will be written in decimal, octal or hexadecimal, respectively. The character n specifies that the offset will not be written. Unless -A n is specified, the output line will be preceded by the input offset, cumulative across input files, of the next byte to be written. In addition, the offset of the byte following the last byte written will be displayed after all the input data has been processed. Without the -A address_base option and the [offset_string] operand, the input offset base is displayed in octal.

-b

Interprets bytes in octal. This is equivalent to -t o1.

"/usr/bin/od"
-c

Displays single-byte characters. Certain non-graphic characters appear as C-language escapes:

null \e0
backspace \eb
form-feed \ef
new-line \en
return \er
tab \et
Others appear as 3-digit octal numbers. For example:
echo "hello world" | od -c
0000000 h e l l o w o r l d \en
0000014
-c

Interprets bytes as single-byte or multibyte characters according to the current setting of the LC_CTYPE locale category. Printable multibyte characters are written in the area corresponding to the first byte of the character. The two-character sequence ** is written in the area corresponding to each remaining byte in the character, as an indication that the character is continued. Non-graphic characters appear the same as they would using the -C option.

-C

Interprets bytes as single-byte or multibyte characters according to the current setting of the LC_CTYPE locale category. Printable multibyte characters are written in the area corresponding to the first byte of the character. The two-character sequence ** is written in the area corresponding to each remaining byte in the character, as an indication that the character is continued. Certain non-graphic characters appear as C escapes:

null \e0
backspace \eb
form-feed \ef
new-line \en
return \er
tab \et
Other non-printable characters appear as one three-digit octal number for each byte in the character.
-d

Interprets words in unsigned decimal. This is equivalent to -t u2.

-D

Interprets long words in unsigned decimal. This is equivalent to -t u4.

-f

Interprets long words in floating point. This is equivalent to -t f4.

-F

Interprets double long words in extended precision. This is equivalent to -t f8.

-j skip

Jumps over skip bytes from the beginning of the input. The od command will read or seek past the first skip bytes in the concatenated input files. If the combined input is not at least skip bytes long, the od command will write a diagnostic message to standard error and exit with a non-zero exit status. By default, the skip option-argument is interpreted as a decimal number. With a leading 0x or 0X, the offset is interpreted as a hexadecimal number; otherwise, with a leading 0, the offset will be interpreted as an octal number. Appending the character b, k, or m to offset will cause it to be interpreted as a multiple of 512, 1024 or 1\|048\|576 bytes, respectively. If the skip number is hexadecimal, any appended b is considered to be the final hexadecimal digit. The address is displayed starting at 0000000, and its base is not implied by the base of the skip option-argument.

-N count

Formats no more than count bytes of input. By default, count is interpreted as a decimal number. With a leading 0x or 0X, count is interpreted as a hexadecimal number; otherwise, with a leading 0, it is interpreted as an octal number. If count bytes of input (after successfully skipping, if -jskip is specified) are not available, it will not be considered an error. The od command will format the input that is available. The base of the address displayed is not implied by the base of the count option-argument.

-o

Interprets words in octal. This is equivalent to -t o2.

-O

Interprets long words in unsigned octal. This is equivalent to -t o4.

-s

Interprets words in signed decimal. This is equivalent to -t d2.

-S

Interprets long words in signed decimal. This is equivalent to -t d4.

-t type_string

Specifies one or more output types. The type_string option-argument must be a string specifying the types to be used when writing the input data. The string must consist of the type specification characters: a

Named character. Interprets bytes as named characters. Only the least significant seven bits of each byte will be used for this type specification. Bytes with the values listed in the following table will be written using the corresponding names for those characters. The following are named characters in od:

Value Name

\000 nul
\001 soh
\002 stx
\003 etx
\004 eot
\005 enq
\006 ack
\007 bel
\010 bs
\011 ht
\012 lf
\013 vt
\014 ff
\015 cr
\016 so
\017 si
\020 dle
\021 dc1
\022 dc2
\023 dc3
\024 dc4
\025 nak
\026 syn
\027 etb
\030 can
\031 em
\032 sub
\033 esc
\034 fs
\035 gs
\036 rs
\037 us
\040 sp
\177 del
c

Character. Interprets bytes as single-byte or multibyte characters specified by the current setting of the LC_CTYPE locale category. Printable multibyte characters are written in the area corresponding to the first byte of the character. The two-character sequence ** is written in the area corresponding to each remaining byte in the character, as an indication that the character is continued. Certain non-graphic characters appear as C escapes: \e0, \ea, \eb, \ef, \en, \er, \et, \ev. Other non-printable characters appear as one three-digit octal number for each byte in the character.

The type specification characters d, f, o, u, and x can be followed by an optional unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type. f

Floating point. Can be followed by an optional F, D, or L indicating that the conversion should be applied to an item of type float, double, or long double, respectively.

d, o, u, and x

Signed decimal, octal, unsigned decimal, and hexadecimal, respectively. Can be followed by an optional C, S, I, or L indicating that the conversion should be applied to an item of type char, short, int, or long, respectively.

Multiple types can be concatenated within the same type_string and multiple -t options can be specified. Output lines are written for each type specified in the order in which the type specification characters are specified.
-v

Shows all input data (verbose). Without the -v option, all groups of output lines that would be identical to the immediately preceding output line (except for byte offsets), will be replaced with a line containing only an asterisk (*).

-x

Interprets words in hex. This is equivalent to -t x2.

-X

Interprets long words in hex. This is equivalent to -t x4.

OPERANDS
"/usr/bin/od"

The following operands are supported for /usr/bin/od only: -

Uses the standard input in addition to any files specified. When this operand is not given, the standard input is used only if no file operands are specified.

file

A path name of a file to be read. If no file operands are specified, the standard input will be used. If there are no more than two operands, none of the -A, -j, -N, or -t options is specified, and any of the following are true:

1. the first character of the last operand is a plus sign (+)

2. the first character of the second operand is numeric

3. the first character of the second operand is x and the second character of the second operand is a lower-case hexadecimal character or digit

4. the second operand is named "x"

5. the second operand is named "."

then the corresponding operand is assumed to be an offset operand rather than a file operand. Without the -N count option, the display continues until an end-of-file is reached.
[+][0] offset [.][b|B]

[+][0][offset] [.]

[+][0x|x][offset]

[+][0x|x] offset[B]

The offset_string operand specifies the byte offset in the file where dumping is to commence. The offset is interpreted in octal bytes by default. If offset begins with "0", it is interpreted in octal. If offset begins with "x" or "0x", it is interpreted in hexadecimal and any appended "b" is considered to be the final hexadecimal digit. If "." is appended, the offset is interpreted in decimal. If "b" or "B" is appended, the offset is interpreted in units of 512 bytes. If the file argument is omitted, the offset argument must be preceded by a plus sign (+). The address is displayed starting at the given offset. The radix of the address will be the same as the radix of the offset, if specified, otherwise it will be octal. Decimal overrides octal, and it is an error to specify both hexadecimal and decimal conversions in the same offset operand.

The following operands are supported for /usr/xpg4/bin/od only: file

Same as /usr/bin/od, except only one of the first two conditions must be true.

[+] [0] offset [.]\|[b|B]

+ [offset] [.]

[+][0x][offset]

[+][0x] offset\|[B]

+x [offset]

+xoffset [B]

Description of offset_string is the same as for /usr/bin/od.

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of od: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, and NLSPATH.

EXIT STATUS

The following exit values are returned: 0

Successful completion.

>0

An error occurred.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

"/usr/bin/od"
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI enabled
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI enabled
Interface Stability Standard
SEE ALSO

sed(1), attributes(5), environ(5), standards(5)