hd, od, xd

formatted file dump 

Command


SYNOPSIS

hd [-bcDdhOoSsXx] [file] [[+]offset[.][b]]

hd [-v] [-A addr_fmt] [-j num [bkm]] [-N num] [-t type_string] [file ...]

od [-bcDdhOoSsXx] [file] [[+]offset[.][b]]

od [-v] [-A addr_fmt] [-j num [bkm]] [-N num] [-t type_string] [file ...]

xd [-bcDdhOoSsXx] [file] [[+]offset[.][b]]

xd [-v] [-A addr_fmt] [-j num [bkm]] [-N num] [-t type_string] [file ...]


DESCRIPTION

od, hd, and xd dump a file to the standard output in a format specified by command line options. The default format for od is octal words and for hd and xd is hexadecimal 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 or hexadecimal) precedes each line of new data.

od, hd and xd each recognize two syntaxes. With the first form, you can specify only a single input file. If no file is specified, the standard input is read. The offset operand indicates the offset, in bytes, in the file where output should begin. When no file is specified, then the offset must be preceded by a plus sign (+) to distinguish it from a file name. If the offset is followed by a period (.), offset is considered to be a decimal number; otherwise, it is considered to be an octal number for od or a hexadecimal number for hd and xd. If the offset is followed with a b, it is multiplied by the block size of 512 bytes. If the -A option is not specified, then the format of the offset determines the format of the address; that is, if the offset is decimal, the file seek addresses are displayed in decimal.

If you choose the second (POSIX-compliant) form, od, hd, and xd display the files listed on the command line one at a time. If no file appears on the command line, od hd, and xd read the standard input.

Options

The first form of od, hd, and xd accepts the following options:

-b 

bytes in octal

-c 

bytes in ASCII

-D 

unsigned decimal longs (4 bytes)

-d 

unsigned decimal words (2 bytes)

-h 

bytes in hex

-O 

unsigned octal longs

-o 

unsigned octal words

-S 

signed decimal longs

-s 

signed decimal words

-X 

unsigned hexadecimal longs

-x 

unsigned hexadecimal words

The second (POSIX-compliant) form accepts the following options:

-A addr_fmt 

specifies the format for displaying the address field. addr_fmt can be d (decimal), o (octal), x (hexadecimal), or n (do not display address).

-j num 

skips num bytes from the beginning of the file. If you precede num with 0X or 0x, it is interpreted as hexadecimal. If you precede it with 0, it is interpreted as octal; otherwise, it is assumed to be decimal. You can also append b, k, or m to num to indicate 512-byte blocks, kilobytes, or megabytes instead of bytes; however, if you append b to a hexadecimal number, it is treated as the number's final hexadecimal digit.

-N num 

processes a maximum of num bytes.

-t type_string 

specifies the output format. type_string may contain the following format characters.

a 
named characters from the ISO 646 character set (similar to the -c option).
c 
characters. Non-printable characters are displayed as backslash sequences and display printable multibyte characters properly.
d 
signed decimal. A one-digit number may follow d specifying how many bytes to use. This must correspond to the size of a char, short, int, or long. The default size is the size of an int. A symbolic size character may follow d, rather than the number of bytes. These have the following meaning:

C 
corresponds to the number of bytes in a char
S 
corresponds to the 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

f 
floating point. A one-digit number may follow f specifying 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 may 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 may follow o specifying how many bytes to use. This must correspond to the size of a char, short, int, or long. The default size is the size of a short. A symbolic size character may follow o, rather than the number of bytes. These have the following meaning:

C 
corresponds to the number of bytes in a char
S 
corresponds to the 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

u 
unsigned decimal. A one-digit number may follow u specifying how many bytes to use. This must correspond to the size of a char, short, int, or long. The default size is the size of an int. A symbolic size character may follow u, rather than the number of bytes. These have the following meaning:

C 
corresponds to the number of bytes in a char
S 
corresponds to the 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

U[b|B|l|L

Unicode. By default, Unicode characters are considered to be little-endian. If a byte-order marker is read, that marker is used to determine the byte order for the characters.

Note:

If the -j option skips over the byte-order marker, the marker is considered to have not been read and the byte order default defaults to little-endian.

You can force Unicode characters to be treated as big-endian by specifying Ub or UB. Similarly, you can force them to be treated as little-endian by specifying Ul or UL.

The hd, od, and xd utilities assume that Unicode characters are double-byte aligned. As a result, if you specify multiple files on the command line and one of those files has an odd number of bytes, subsequent Unicode files will not be properly double-byte aligned and will display incorrectly. Also, if a specified file is not a Unicode file, but does contain Unicode strings that are not necessarily double-byte aligned, you should use strings -U to display those strings.

x 
hexadecimal. A one-digit number may follow x specifying how many bytes to use. This must correspond to the size of a char, short, int, or long. The default size is the size of an int. A symbolic size character may 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

Multiple format characters can appear in one type_string and multiple -t options may appear on the command line. If there is no -t option, the default is -t oS for od and -t xS for hd and xd.

-v 

displays all lines. Normally, the hd, od, and xd utilities do not display multiple lines that differ only in the address. They display the first line with a single * in it to show that any subsequent lines are the same.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— inability to open the input file
— badly formed offset
— an offset that is not a multiple of 512
— seek or read error on the input file
2 

Failure due to any of the following:

— invalid command line argument
— the wrong number of command line arguments
— invalid format character
— invalid size modifier for format character


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.

Only the second form of the od command line is part of the POSIX standard. The first form is an x/OPEN extension to the POSIX standard.

The hd and xd utilities, the ability to display Unicode, the options to operate on longs (-OSXD), and the -h option are extensions to both the POSIX and x/OPEN standards.

On Windows systems, a file name consisting of a letter followed by a colon (as in C:) is operated upon by using raw disk I/O, thus allowing hd, od, and xd to examine raw disk contents.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
dd


PTC MKS Toolkit 10.4 Documentation Build 39.