Skip to content

od

od is a command that dumps binary files to eight digits.

Terminal window
od [-aBbcDdeFfHhIiLlOosvXx] [-A base] [-j skip] [-N length] [-t type]
[[+]offset[.][Bb]] [file ...]
OptionDescription
-A baseSpecify the input address base. The argument base may be one of d, o, x or n, which specify decimal, octal, hexadecimal addresses or no address, respectively.
-aOutput named characters. Equivalent to -t a.
-B, -oOutput octal shorts. Equivalent to -t o2.
-bOutput octal bytes. Equivalent to -t o1.
-cOutput C-style escaped characters. Equivalent to -t c.
-DOutput unsigned decimal ints. Equivalent to -t u4.
-dOutput unsigned decimal shorts. Equivalent to -t u2.
-e, -FOutput double-precision floating point numbers. Equivalent to -t fD.
-fOutput single-precision floating point numbers. Equivalent to -t fF.
-H, -XOutput hexadecimal ints. Equivalent to -t x4.
-h, -xOutput hexadecimal shorts. Equivalent to -t x2.
-I, -L, -lOutput signed decimal longs. Equivalent to -t dL.
-iOutput signed decimal ints. Equivalent to -t dI.
-j skipSkip skip bytes of the combined input before dumping. The number may be followed by one of b, k, m or g which specify the units of the number as blocks (512 bytes), kilobytes, megabytes and gigabytes, respectively.
-N lengthDump at most length bytes of input.
-OOutput octal ints. Equivalent to -t o4.
-sOutput signed decimal shorts. Equivalent to -t d2.
-t typeSpecify the output format. The type argument is a string containing one or more of the following kinds of type specifiers.
aNamed characters (ASCII). Control characters are displayed using the following names:image
cCharacters in the default character set. Non-printing characters are represented as 3-digit octal character codes, except the following characters, which are represented as C escapes like \0, \n, \t, so on. Multi-byte characters are displayed in the area corresponding to the first byte of the character. The remaining bytes are shown as ‘**’.
[do
f[FD
-vWrite all input data, instead of replacing lines of duplicate values with a ‘*’.

Example

File test’s content is:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890

od -t x1 test -> Express the test file by 1 byte in hexadecimal.

Terminal window
$ od -t x1 test
0000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70
0000020 71 72 73 74 75 76 77 78 79 7a 41 42 43 44 45 46
0000040 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56
0000060 57 58 59 5a 31 32 33 34 35 36 37 38 39 30 0a
0000077

od -t x1z test -> Express 1 byte by hexadecimal and display ASCII characters on the below.

Terminal window
$ od -t x1c test
0000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70
a b c d e f g h i j k l m n o p
0000020 71 72 73 74 75 76 77 78 79 7a 41 42 43 44 45 46
q r s t u v w x y z A B C D E F
0000040 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56
G H I J K L M N O P Q R S T U V
0000060 57 58 59 5a 31 32 33 34 35 36 37 38 39 30 0a
W X Y Z 1 2 3 4 5 6 7 8 9 0 \n
0000077

od -Ad test -> Print as demical.

Terminal window
$ od -Ad test
0000000 061141 062143 063145 064147 065151 066153 067155 070157
0000016 071161 072163 073165 074167 075171 041101 042103 043105
0000032 044107 045111 046113 047115 050117 051121 052123 053125
0000048 054127 055131 031061 032063 033065 034067 030071 000012
0000063

reference