my-server
← Wiki

Od (Unix)

<code>od</code> is a command on various operating systems for displaying ("dumping") data in various human-readable output formats. The name is an acronym for "octal dump" since it defaults to printing in the octal data format.

Overview

The <code>od</code> program can display output in a variety of formats, including octal, hexadecimal, decimal, and ASCII. It is useful for visualizing data that is not in a human-readable format, like the executable code of a program, or where the primary form is ambiguous (e.g. some Latin, Greek and Cyrillic characters looking similar).

<code>od</code> is one of the earliest Unix programs, having appeared in version 1 AT&T Unix. It is also specified in the POSIX standards. The implementation for <code>od</code> used on Linux systems is usually provided by GNU Core Utilities.

Since it predates the Bourne shell, its existence causes an inconsistency in the <code>do</code> loop syntax. Other loops and logical blocks are opened by the name, and closed by the reversed name, e.g. <code>if ... fi</code> and <code>case ... esac</code>, but <code>od</code>'s existence necessitates <code>do ... done</code>.

The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. The command has also been ported to the IBM i operating system.

Example session

Normally a dump of an executable file is very long. The <code>head</code> program prints out the first few lines of the output. Here is an example of a dump of the "Hello world" program, piped through head.

Here is an example of <code>od</code> used to diagnose the output of <code>echo</code> where the user types and after writing "Hello" to literal insert a tab and <code>^C</code> character:

can be used to fetch random numbers from the cryptographic-quality random number generator /dev/urandom. For example:

See also

References

External links