xref: /freebsd/usr.bin/hexdump/od.1 (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)od.1	8.1 (Berkeley) 6/6/93
29.\"
30.Dd December 22, 2011
31.Dt OD 1
32.Os
33.Sh NAME
34.Nm od
35.Nd octal, decimal, hex, ASCII dump
36.Sh SYNOPSIS
37.Nm
38.Op Fl aBbcDdeFfHhIiLlOosvXx
39.Op Fl A Ar base
40.Op Fl j Ar skip
41.Op Fl N Ar length
42.Op Fl t Ar type
43.Op Oo Cm + Oc Ns Ar offset Ns Oo Cm \&. Oc Ns Op Cm Bb
44.Op Ar
45.Sh DESCRIPTION
46The
47.Nm
48utility is a filter which displays the specified files, or standard
49input if no files are specified, in a user specified format.
50.Pp
51The options are as follows:
52.Bl -tag -width ".Fl I , L , l"
53.It Fl A Ar base
54Specify the input address base.
55The argument
56.Ar base
57may be one of
58.Cm d ,
59.Cm o ,
60.Cm x
61or
62.Cm n ,
63which specify decimal, octal, hexadecimal
64addresses or no address, respectively.
65.It Fl a
66Output named characters.
67Equivalent to
68.Fl t Cm a .
69.It Fl B , o
70Output octal shorts.
71Equivalent to
72.Fl t Cm o2 .
73.It Fl b
74Output octal bytes.
75Equivalent to
76.Fl t Cm o1 .
77.It Fl c
78Output C-style escaped characters.
79Equivalent to
80.Fl t Cm c .
81.It Fl D
82Output unsigned decimal ints.
83Equivalent to
84.Fl t Cm u4 .
85.It Fl d
86Output unsigned decimal shorts.
87Equivalent to
88.Fl t Cm u2 .
89.It Fl e , F
90Output double-precision floating point numbers.
91Equivalent to
92.Fl t Cm fD .
93.It Fl f
94Output single-precision floating point numbers.
95Equivalent to
96.Fl t Cm fF .
97.It Fl H , X
98Output hexadecimal ints.
99Equivalent to
100.Fl t Cm x4 .
101.It Fl h , x
102Output hexadecimal shorts.
103Equivalent to
104.Fl t Cm x2 .
105.It Fl I , L , l
106Output signed decimal longs.
107Equivalent to
108.Fl t Cm dL .
109.It Fl i
110Output signed decimal ints.
111Equivalent to
112.Fl t Cm dI .
113.It Fl j Ar skip
114Skip
115.Ar skip
116bytes of the combined input before dumping.
117The number may be followed by one
118of
119.Cm b , k
120or
121.Cm m
122which specify the units of the number as blocks (512 bytes), kilobytes and
123megabytes, respectively.
124.It Fl N Ar length
125Dump at most
126.Ar length
127bytes of input.
128.It Fl O
129Output octal ints.
130Equivalent to
131.Fl t Cm o4 .
132.It Fl s
133Output signed decimal shorts.
134Equivalent to
135.Fl t Cm d2 .
136.It Fl t Ar type
137Specify the output format.
138The
139.Ar type
140argument
141is a string containing one or more of the following kinds of type specifiers:
142.Bl -tag -width indent
143.It Cm a
144Named characters
145.Pq ASCII .
146Control characters are displayed using the following names:
147.Bl -column "000 NUL" "001 SOH" "002 STX" "003 ETX" "004 EOT" "005 ENQ"
148.It "000 NUL	001 SOH	002 STX	003 ETX	004 EOT	005 ENQ"
149.It "006 ACK	007 BEL	008 BS	009 HT	00A NL	00B VT"
150.It "00C FF	00D CR	00E SO	00F SI	010 DLE	011 DC1"
151.It "012 DC2	013 DC3	014 DC4	015 NAK	016 SYN	017 ETB"
152.It "018 CAN	019 EM	01A SUB	01B ESC	01C FS	01D GS"
153.It "01E RS	01F US	020 SP	07F DEL	\&	\&"
154.El
155.It Cm c
156Characters in the default character set.
157Non-printing characters are
158represented as 3-digit octal character codes, except the following
159characters, which are represented as C escapes:
160.Pp
161.Bl -tag -width carriage-return -compact
162.It NUL
163\e0
164.It alert
165\ea
166.It backspace
167\eb
168.It newline
169\en
170.It carriage-return
171\er
172.It tab
173\et
174.It vertical tab
175\ev
176.El
177.Pp
178Multi-byte characters are displayed in the area corresponding to the first
179byte of the character.
180The remaining bytes are shown as
181.Ql ** .
182.It Xo
183.Sm off
184.Op Cm d | o | u | x
185.Op Cm C | S | I | L | Ar n
186.Sm on
187.Xc
188Signed decimal
189.Pq Cm d ,
190octal
191.Pq Cm o ,
192unsigned decimal
193.Pq Cm u
194or
195hexadecimal
196.Pq Cm x .
197Followed by an optional size specifier, which may be either
198.Cm C
199.Pq Vt char ,
200.Cm S
201.Pq Vt short ,
202.Cm I
203.Pq Vt int ,
204.Cm L
205.Pq Vt long ,
206or a byte count as a decimal integer.
207.It Xo
208.Sm off
209.Cm f
210.Op Cm F | D | L | Ar n
211.Sm on
212.Xc
213Floating-point number.
214Followed by an optional size specifier, which may be either
215.Cm F
216.Pq Vt float ,
217.Cm D
218.Pq Vt double
219or
220.Cm L
221.Pq Vt "long double" .
222.El
223.It Fl v
224Write all input data, instead of replacing lines of duplicate values with a
225.Ql * .
226.El
227.Pp
228Multiple options that specify output format may be used; the output will
229contain one line for each format.
230.Pp
231If no output format is specified,
232.Fl t Cm oS
233is assumed.
234.Sh ENVIRONMENT
235The
236.Ev LANG , LC_ALL
237and
238.Ev LC_CTYPE
239environment variables affect the execution of
240.Nm
241as described in
242.Xr environ 7 .
243.Sh EXIT STATUS
244.Ex -std
245.Sh EXAMPLES
246Dump stdin and show the output using named characters and C-style escaped
247characters:
248.Bd -literal -offset indent
249$ echo "FreeBSD: The power to serve" | od -a -c
2500000000    F   r   e   e   B   S   D   :  sp   T   h   e  sp   p   o   w
251           F   r   e   e   B   S   D   :       T   h   e       p   o   w
2520000020    e   r  sp   t   o  sp   s   e   r   v   e  nl
253           e   r       t   o       s   e   r   v   e  \en
2540000034
255.Ed
256.Pp
257Dump stdin skipping the first 13 bytes using named characters and dumping no
258more than 5 bytes:
259.Bd -literal -offset indent
260$ echo "FreeBSD: The power to serve" | od -An -a -j 13 -N 5
261           p   o   w   e   r
262.Ed
263.Sh COMPATIBILITY
264The traditional
265.Fl s
266option to extract string constants is not supported; consider using
267.Xr strings 1
268instead.
269.Sh SEE ALSO
270.Xr hexdump 1 ,
271.Xr strings 1
272.Sh STANDARDS
273The
274.Nm
275utility conforms to
276.St -p1003.1-2001 .
277.Sh HISTORY
278An
279.Nm
280command appeared in
281.At v1 .
282