[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 4


od Command

Purpose

Displays files in a specified format.

Syntax

To Display Files Using a Type-String to Format the Output

od-v ] [  -A AddressBase ] [  -N Count ] [  -j Skip ] [  -t TypeString ... ] [ File ... ]

To Display a File Using Flags to Format the Output

od-a ] [  -b ] [  -c ] [  -C ] [  -d ] [  -D ] [  -e ] [  -f ] [  -F ] [  -h ] [  -H ] [  -i ] [  -I ] [  -l ] [  -L ] [  -o ] [  -O ] [  -p ] [  -P ] [  -s ] [  -v ] [  -x ] [  -X ] [ [  -S ] ] [  -w ] ] [ File ] [ [ Offset] [ Label ] ]

Description

The od command displays the file specified by the File parameter in the format specified. If the File parameter is not given, the od command reads standard input. Multiple types can be specified by using multiple -bcCDdFfOoSstvXx options.

In the first syntax format, the output format is specified by the -t flag. If no format type is specified, -t o2 is the default.

In the second syntax format, the output format is specified by a combination of flags. The Offset parameter specifies the point in the file where the file output begins. By default, the Offset parameter is interpreted as octal bytes. If the . (dot) suffix is appended, the parameter is interpreted as a decimal; if the parameter begins with a leading x or 0x, it is treated as a hexadecimal. If the b suffix is added to the parameter, it is interpreted in blocks of 512 bytes; if the B suffix is added to the parameter, it is interpreted in blocks of 1024 bytes.

The Label parameter is interpreted as a pseudo-address for the first byte displayed. If used, it is given in ( ) (parentheses) following the Offset parameter. The suffixes have the same meanings as for the Offset parameter.

When the od command reads standard input, the Offset parameter and the Label parameter must be preceded by a + (plus sign).

The setting of environment variables such as LANG and LC_ALL affects the operation of the od command. See "Understanding Locale Environment Variables" in AIX 5L Version 5.1 System Management Guide: Operating System and Devices for more information.

Flags

The flags for the first format are:

-A AddressBase Specifies the input offset base. The AddressBase variable is one of the following characters:

d
Offset base is written in decimal.

o
Offset base is written in octal.

x
Offset base is written in hexadecimal.

n
Offset base is not displayed.

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.

-j Skip

Jumps over the number of bytes given by the Skip variable before beginning to display output. If more than one file is specified, the od command jumps over the designated number of bytes of the concatenated input files before displaying output. If the combined input is not at least the length of the skip bytes, the od command will write a diagnostic message to standard error and exit non-zero status.

By default, the value of the Skip variable 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 shall be interpreted as an octal number. If the characters b, k, or m are appended to the number contained by the Skip variable, the offset is equal to the value, in bytes, of the Skip variable multiplied by 512, 1024, or 1024*1024, respectively.

-N Count Formats no more than the number of input bytes specified by the Count variable. By default, the value of the Count variable is interpreted as a decimal number. With a leading 0x or 0X, it is treated as a hexadecimal number. If it begins with a 0, it is treated as an octal number. The base of the address displayed is not implied by the base of the Count option-argument.
-t TypeString Specifies the output type. The TypeString variable is a string specifying the types to be used when writing out data. Multiple types can be concatenated within the same TypeString variable, and the -t flag can be specified more than once. Output lines are written for each type specified, in the order in which the type specification characters are given. The TypeString variable can consist of the following characters:

a
Displays bytes as named characters. Bytes with the least seven bits in the range of 0 through 01777 are written using the corresponding names for those characters.

c
Displays bytes as characters. The number of bytes transformed by the c type string is determined by the LC_CTYPE local 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. The following nongraphic characters are used as C-language escape sequences:

\    Backslash
\a   Alert
\b   Backspace
\f   Form-feed
\n   New-line character
\0   Null
\r   Carriage return
\t   Tab
\v   Vertical tab

d
Displays bytes as signed decimals. By default, the od command transforms the corresponding number of bytes in the C-language type int. The d type string can be followed by an unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type.

An optional C, I, L, or S character can be appended to the d option, indicating that the conversion should be applied to an item of type char, int, long, or short, respectively.

f
Displays bytes as floating points. By default, the od command transforms the corresponding number of bytes in the C-language type double. The f type string can be followed by an unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type.

An optional F, D, or L character can be appended to the f option, indicating that the conversion should be applied to an item of type float, double, or long double, respectively.



o
Displays bytes as octals. By default, the od command transforms the corresponding number of bytes in the C-language type int. The o type string can be followed by an unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type.

An optional C, I, L, or S character can be appended to the o option, indicating that the conversion should be applied to an item of type char, int, long, or short, respectively.



u
Display bytes as unsigned decimal. By default, the od command transforms the corresponding number of bytes in the C-language type int. The u type string can be followed by an unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type.

An optional C, I, L, or S character can be appended to the u option, indicating that the conversion should be applied to an item of type char, int, long, or short, respectively.

x
Display bytes as hexadecimal. By default, the od command transforms the corresponding number of bytes in the C-language type int. The x type string can be followed by an unsigned decimal integer that specifies the number of bytes to be transformed by each instance of the output type.

An optional C, I, L, or S character can be appended to the x option, indicating that the conversion should be applied to an item of type char, int, long, or short, respectively.


The flags for the second format are:

-a Displays bytes as characters and displays them with their ASCII names. If the -p flag is also given, bytes with even parity are underlined. The -P flag causes bytes with odd parity to be underlined. Otherwise, parity is ignored.
-b Displays bytes as octal values.
-c Displays bytes as ASCII characters. The following nongraphic characters appear as C-language escape sequences:

\    Backslash
\a   Alert
\b   Backspace
\f   Form-feed
\n   New-line character
\0   Null
\r   Carriage return
\t   Tab
\v   Vertical tab

Others appear as three-digit octal numbers.

-C Displays extended characters as standard printable ASCII characters (using the appropriate character escape string) and displays multibyte characters in hexadecimal form.
-d Displays 16-bit words as unsigned decimal values.
-D Displays long words as unsigned decimal values.
-e Displays long words as double-precision, floating point. (same as the -F flag)
-f Displays long words as floating points.
-F Displays long words as double-precision, floating point. (same as the -e flag)
-h Displays 16-bit words as unsigned hexadecimal.
-H Displays long words as unsigned hexadecimal values.
-i Displays 16-bit words as signed decimal.
-I (Uppercase i) Displays long words as signed decimal values.
-l (Lowercase L) Displays long words as signed decimal values.
-L Displays long words as signed decimal values.

Note: The flags -I (uppercase i), -l (lowercase L), and -L are identical.

-o Displays 16-bit words as unsigned octal.
-O Displays long words as unsigned octal values.
-p Indicates even parity on -a conversion.
-P Indicates odd parity on -a conversion.
-s Displays 16-bit words as signed decimal values.
-S[N] Searches for strings of characters ending with a null byte. The N variable specifies the minimum length string to be recognized. If the N variable is omitted, the minimum length defaults to 3 characters.

The -v flag is the same for both formats:

-v Writes all input data. By default, output lines that are identical to the immediately preceding output lines are not printed, but are replaced with a line containing only an * (asterisk). When the -v flag is specified, all the lines are printed.
-w [N] Specifies the number of input bytes to be interpreted and displayed on each output line. If the -w flag is not specified, 16 bytes are read for each display line. If the -w flag is specified without the N variable, 32 bytes are read for each display line. The maximum input value is 4096 bytes. Input values greater than 4096 bytes will be reassigned the maximum value.
-x Displays 16-bit words as hexadecimal values.
-X Displays long words as unsigned hexadecimal values. (same as the -H flag)

Exit Status

This command returns the following exit values:

0 All input files were processed successfully.
>0 An error occurred.

Examples

  1. To display a file in octal, a page at a time, enter:

    od a.out | pg
    

    This command displays the a.out file in octal format and pipes the output through the pg command.

  2. To translate a file into several formats at once, enter:

    od -t cx a.out > a.xcd
    

    This command writes the contents of the a.out file, in hexadecimal format ( x) and character format ( c), into the a.xcd file.

  3. To start displaying a file in the middle (using the first syntax format), enter:

    od -t acx -j 100 a.out
    

    This command displays the a.out file in named character ( a), character ( c), and hexadecimal ( x) formats, starting from the 100th byte.

  4. To start in the middle of a file (using the second syntax format), enter:

    od -bcx a.out +100.
    

    This displays the a.out file in octal-byte ( -b), character ( -c), and hexadecimal ( -x) formats, starting from the 100th byte. The . (period) after the offset makes it a decimal number. Without the period, the output would start from the 64th (100 octal) byte.

Files


/usr/bin/od Contains the od command.

Related Information

The dbx command, pg command.

The National Language Support Overview for System Management and Understanding Locale Environment Variables in AIX 5L Version 5.1 System Management Guide: Operating System and Devices.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]