hd(1)
hd --
display files in a specified format
Synopsis
hd [-[abwl][xdo][cAS][t]] [-s offset] [-n count] [file]
Description
The hd command displays the contents of files in hexadecimal
octal, decimal, and character formats.
Control over the specification
of ranges of characters is also available.
The default behavior is with
the following specifiers set: -abA.
This says that addresses
(file offsets) and bytes are printed in hexadecimal and that
only ASCII characters are also printed.
If no file argument is given, the
standard input is read.
Command options
Format specifiers, described below,
may specify addresses, bytes, words (2 bytes),
or longs (4 bytes).
Output specifiers determine whether to print only
the ASCII-readable
characters, or to print all printable characters, special C
escapes as defined in the language, and remaining values in
the specified base.
Base specifiers determine whether the data is
to be printed in hexadecimal, decimal, or octal.
A special flag directs output to a test file,
with each line preceded by the address in the file.
Format and base specifiers may be freely
combined and repeated as desired
in order to specify different bases (hexadecimal, decimal,
and/or octal)
for different formats (addresses, bytes, and so on).
All format specifiers appearing in a single argument are
applied as appropriate to all other flags in that argument.
If no
format specifier is given, -abwlc is used as the default.
If no other output format (other than addresses, a)
is given, bx is assumed (byte, in hexadecimal).
Format specifiers are used as follows:
-abwl-
Format type specifier for address, bytes, words, and longs,
respectively.
Only one base specifier (described below) is used
for addresses; the address appears on the first line of output
that begins each new offset in the input.
cAS-
These are the output specifiers, and should be entered directly to
the right of one or more of the format type specifiers (that
is, a, b, w, or l).
If only one output specifier appears on the command line,
it is assumed to apply to all the format type specifiers.
The character format flag, c, directs hd to
print printable characters unchanged, special
C escapes as defined in the language, and remaining values
in the specified base.
The format flag A directs hd to
print all printable characters unchanged, and
all others as a period (.).
The format flag S directs hd to
print all 7 bit printable ASCII characters unchanged, and
all others as a period (.).
xdo-
The base specifiers denote hexadecimal, decimal and octal.
If no base specifier is given, the default is
xdo, meaning present the output in all
three formats, hexadecimal, decimal, and octal.
t-
Print a test file, each line preceded by the address in the file.
Normally, lines should be terminated by a \n character; but long
lines will be broken up.
Control characters in the range 0x00 to 0x1f
are printed as `^@' to `^_'.
Bytes with the high bit set
are preceded by a tilde (~) and printed as if the high bit were not set.
The special characters (^,~,\) are preceded by a backslash (\)
to escape their special meaning.
As special cases, two values are
represented numerically as `\177' and `\377'.
This flag will
override all output format specifiers except addresses.
Following are the remaining options for hd:
-s offset-
Specify the beginning offset in the file where printing is to begin.
If no `file' argument is given, or if a seek fails because the input
is a pipe, `offset' bytes are read from the input and discarded.
Otherwise, a seek error will terminate processing of the current file.
The offset may be given in decimal, hexadecimal (preceded by
`Ox'), or octal (preceded by a `0').
It is optionally followed by
one of the following
multipliers: w, l, b, or k; for words
(2 bytes), long words (4 bytes), blocks (512 bytes), or K bytes
(1024 bytes).
Note that this is the one case where "b" does not
stand for bytes.
Since specifying a hexadecimal offset in blocks
would result in an ambiguous trailing `b', any offset and
multiplier may be separated by an asterisk (*).
-n count-
Specify the number of bytes to process.
The count is in the same
format as offset, above.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004