Od (Unix)
The Unix command od
is used to create a dump in various human-readable formats . The name is derived from the acronym " o ctal d ump ", since the command outputs the data in the octal system by default .
In addition to the octal , od
data can also be optionally output in the hexadecimal and decimal number system as well as in ASCII .
Examples
Executable files
od
helps with the visualization of data with non-human-readable format such as B. the executable files of a program . The dump of such an executable usually produces a very long output . It is therefore advisable to forward the original output with the Unix pipeline |
to the head
command. This only outputs the first lines of the octal representation of the hello world program hello
:
% od hello | head
0000000 042577 043114 000401 000001 000000 000000 000000 000000
0000020 000002 000003 000001 000000 101400 004004 000064 000000
0000040 003610 000000 000000 000000 000064 000040 000006 000050
0000060 000033 000030 000006 000000 000064 000000 100064 004004
0000100 100064 004004 000300 000000 000300 000000 000005 000000
0000120 000004 000000 000003 000000 000364 000000 100364 004004
0000140 100364 004004 000023 000000 000023 000000 000004 000000
0000160 000001 000000 000001 000000 000000 000000 100000 004004
0000200 100000 004004 002121 000000 002121 000000 000005 000000
0000220 010000 000000 000001 000000 002124 000000 112124 004004
Strings
The od
command makes it easier to examine strings with invisible characters such as control keys ( ^) in the command line that were unintentionally issued . The latter is a frequent careless mistakes by in the graphical user interface familiar keyboard shortcuts Ctrl-C and Ctrl-V for copying and pasting . In the example gives echo
command the string "Hello," a tab ( Strg+ Vand Strg+ I) and a control character followed by characters "C" ( Strg+ Vand Strg+ Cfrom). The Unix pipeline finally forwards the result to the od
command:
% echo "Hallo ^C" | od -cb
0000000 H e l l o \t 003 \n
110 145 154 154 157 011 003 012
0000010
The options b
and c
activate the readout and the output for the octal notation including the control characters per character .
history
od
is one of the earliest Unix - programs of Version 1 AT & T Unix and part of the POSIX standard . Linux systems od
usually provided through the GNU Core Utilities . Its beginnings date before the introduction of the Bourne shell , so its use causes inconsistencies with the syntax of do
loops . Loops and logical units usually open with names and end with reversed names, e.g. E.g .: if ... fi
and case ... esac
. However, the use of od
requires the use of the syntax do ... done
.
See also
Web links
-
od(3)
- Open Group Base Specification - Manpage of the GNU Core Utilities for od