OD(1P) | POSIX Programmer's Manual | OD(1P) |
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
od — dump files in various formats
od [-v] [-A address_base] [-j skip] [-N count] [-t type_string]...
[file...]
od [-bcdosx] [file] [[+]offset[.][b]]
The od utility shall write the contents of its input files to standard output in a user-specified format.
The od utility shall conform to the Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines, except that the order of presentation of the -t options and the -bcdosx options is significant.
The following options shall be supported:
By default, the skip option-argument shall be interpreted as a decimal number. With a leading 0x or 0X, the offset shall be interpreted as a hexadecimal number; otherwise, with a leading '0', the offset shall be interpreted as an octal number. Appending the character 'b', 'k', or 'm' to offset shall cause it to be interpreted as a multiple of 512, 1024, or 1048576 bytes, respectively. If the skip number is hexadecimal, any appended 'b' shall be considered to be the final hexadecimal digit.
Multiple types can be specified by using multiple -bcdostx options. Output lines are written for each type specified in the order in which the types are specified.
The following operands shall be supported:
If there are no more than two operands, none of the -A, -j, -N, -t, or -v options is specified, and either of the following is true: the first character of the last operand is a <plus-sign> ('+'), or there are two operands and the first character of the last operand is numeric; the last operand shall be interpreted as an offset operand on XSI-conformant systems. Under these conditions, the results are unspecified on systems that are not XSI-conformant systems.
The standard input shall be used if no file operands are specified, and shall be used if a file operand is '-' and the implementation treats the '-' as meaning standard input. Otherwise, the standard input shall not be used. See the INPUT FILES section.
The input files can be any file type.
The following environment variables shall affect the execution of od:
Default.
See the EXTENDED DESCRIPTION section.
The standard error shall be used only for diagnostic messages.
None.
The od utility shall copy sequentially each input file to standard output, transforming the input data according to the output types specified by the -t option or the -bcdosx options. If no output type is specified, the default output shall be as if -t oS had been specified.
The number of bytes transformed by the output type specifier c may be variable depending on the LC_CTYPE category.
The default number of bytes transformed by output type specifiers d, f, o, u, and x corresponds to the various C-language types as follows. If the c99 compiler is present on the system, these specifiers shall correspond to the sizes used by default in that compiler. Otherwise, these sizes may vary among systems that conform to POSIX.1‐2008.
The type specifier character a specifies that bytes shall be interpreted as named characters from the International Reference Version (IRV) of the ISO/IEC 646:1991 standard. Only the least significant seven bits of each byte shall be used for this type specification. Bytes with the values listed in the following table shall be written using the corresponding names for those characters.
Table: Named Characters in od
Value | Name | Value | Name | Value | Name | Value | Name |
\000 | nul | \001 | soh | \002 | stx | \003 | etx |
\004 | eot | \005 | enq | \006 | ack | \007 | bel |
\010 | bs | \011 | ht | \012 | lf or nl* | \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 |
The type specifier character c specifies that bytes shall be interpreted as characters specified by the current setting of the LC_CTYPE locale category. Characters listed in the table in the Base Definitions volume of POSIX.1‐2017, Chapter 5, File Format Notation ('\\', '\a', '\b', '\f', '\n', '\r', '\t', '\v') shall be written as the corresponding escape sequences, except that <backslash> shall be written as a single <backslash> and a NUL shall be written as '\0'. Other non-printable characters shall be written as one three-digit octal number for each byte in the character. Printable multi-byte characters shall be written in the area corresponding to the first byte of the character; the two-character sequence "**" shall be written in the area corresponding to each remaining byte in the character, as an indication that the character is continued. When either the -j skip or -N count option is specified along with the c type specifier, and this results in an attempt to start or finish in the middle of a multi-byte character, the result is implementation-defined.
The input data shall be manipulated in blocks, where a block is defined as a multiple of the least common multiple of the number of bytes transformed by the specified output types. If the least common multiple is greater than 16, the results are unspecified. Each input block shall be written as transformed by each output type, one per written line, in the order that the output types were specified. If the input block size is larger than the number of bytes transformed by the output type, the output type shall sequentially transform the parts of the input block, and the output from each of the transformations shall be separated by one or more <blank> characters.
If, as a result of the specification of the -N option or end-of-file being reached on the last input file, input data only partially satisfies an output type, the input shall be extended sufficiently with null bytes to write the last byte of the input.
Unless -A n is specified, the first output line produced for each input block shall be preceded by the input offset, cumulative across input files, of the next byte to be written. The format of the input offset is unspecified; however, it shall not contain any <blank> characters, shall start at the first character of the output line, and shall be followed by one or more <blank> characters. In addition, the offset of the byte following the last byte written shall be written after all the input data has been processed, but shall not be followed by any <blank> characters.
If no -A option is specified, the input offset base is unspecified.
The following exit values shall be returned:
Default.
The following sections are informative.
XSI-conformant applications are warned not to use filenames starting with '+' or a first operand starting with a numeric character so that the old functionality can be maintained by implementations, unless they specify one of the -A, -j, or -N options. To guarantee that one of these filenames is always interpreted as a filename, an application could always specify the address base format with the -A option.
If a file containing 128 bytes with decimal values zero to 127, in increasing order, is supplied as standard input to the command:
od -A d -t a
on an implementation using an input block size of 16 bytes, the standard output, independent of the current locale setting, would be similar to:
0000000 nul soh stx etx eot enq ack bel bs ht nl vt ff cr so si 0000016 dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us 0000032 sp ! " # $ % & ' ( ) * + , - . / 0000048 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0000064 @ A B C D E F G H I J K L M N O 0000080 P Q R S T U V W X Y Z [ \ ] ^ _ 0000096 ` a b c d e f g h i j k l m n o 0000112 p q r s t u v w x y z { | } ~ del 0000128
Note that this volume of POSIX.1‐2017 allows nl or lf to be used as the name for the ISO/IEC 646:1991 standard IRV character with decimal value 10. The IRV names this character lf (line feed), but traditional implementations have referred to this character as newline (nl) and the POSIX locale character set symbolic name for the corresponding character is a <newline>.
The command:
od -A o -t o2x2x -N 18
on a system with 32-bit words and an implementation using an input block size of 16 bytes could write 18 bytes in approximately the following format:
0000000 032056 031440 041123 042040 052516 044530 020043 031464
342e 3320 4253 4420 554e 4958 2023 3334
342e3320 42534420 554e4958 20233334 0000020 032472
353a
353a0000 0000022
The command:
od -A d -t f -t o4 -t x4 -N 24 -j 0x15
on a system with 64-bit doubles (for example, IEEE Std 754‐1985 double precision floating-point format) would skip 21 bytes of input data and then write 24 bytes in approximately the following format:
0000000 1.00000000000000e+00 1.57350000000000e+01
07774000000 00000000000 10013674121 35341217270
3ff00000 00000000 402f3851 eb851eb8 0000016 1.40668230000000e+02
10030312542 04370303230
40619562 23e18698 0000024
The od utility went through several names in early proposals, including hd, xd, and most recently hexdump. There were several objections to all of these based on the following reasons:
The original reasons for not standardizing historical od were also fairly widespread. Those reasons are given below along with rationale explaining why the standard developers believe that this version does not suffer from the indicated problem:
The sizes of the C-language types char, short, int, long, float, double, and long double are used even though it is recognized that there may be zero or more than one compiler for the C language on an implementation and that they may use different sizes for some of these types. (For example, one compiler might use 2 bytes shorts, 2 bytes ints, and 4 bytes longs, while another compiler (or an option to the same compiler) uses 2 bytes shorts, 4 bytes ints, and 4 bytes longs.) Nonetheless, there has to be a basic size known by the implementation for these types, corresponding to the values reported by invocations of the getconf utility when called with system_var operands {UCHAR_MAX}, {USHORT_MAX}, {UINT_MAX}, and {ULONG_MAX} for the types char, short, int, and long, respectively. There are similar constants required by the ISO C standard, but not required by the System Interfaces volume of POSIX.1‐2017 or this volume of POSIX.1‐2017. They are {FLT_MANT_DIG}, {DBL_MANT_DIG}, and {LDBL_MANT_DIG} for the types float, double, and long double, respectively. If the optional c99 utility is provided by the implementation and used as specified by this volume of POSIX.1‐2017, these are the sizes that would be provided. If an option is used that specifies different sizes for these types, there is no guarantee that the od utility is able to interpret binary data output by such a program correctly.
This volume of POSIX.1‐2017 requires that the numeric values of these lengths be recognized by the od utility and that symbolic forms also be recognized. Thus, a conforming application can always look at an array of unsigned long data elements using od -t uL.
The use of "**" as an indication of continuation of a multi-byte character in c specifier output was chosen based on seeing an implementation that uses this method. The continuation bytes have to be marked in a way that is not ambiguous with another single-byte or multi-byte character.
An early proposal used -S and -n, respectively, for the -j and -N options eventually selected. These were changed to avoid conflicts with historical implementations.
The original standard specified -t o2 as the default when no output type was given. This was changed to -t oS (the length of a short) to accommodate a supercomputer implementation that historically used 64 bits as its default (and that defined shorts as 64 bits). This change should not affect conforming applications. The requirement to support lengths of 1, 2, and 4 was added at the same time to address an historical implementation that had no two-byte data types in its C compiler.
The use of a basic integer data type is intended to allow the implementation to choose a word size commonly used by applications on that architecture.
Earlier versions of this standard allowed for implementations with bytes other than eight bits, but this has been modified in this version.
All option and operand interfaces marked XSI may be removed in a future version.
c99, sed
The Base Definitions volume of POSIX.1‐2017, Chapter 5, File Format Notation, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version 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 .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2017 | IEEE/The Open Group |