od
Dump file contents in various formats
TLDR
Display file using default settings: octal format, 8 bytes per line, byte offsets in octal, and duplicate lines replaced with *
Display file in verbose mode, i.e. without replacing duplicate lines with *
Display file in hexadecimal format (2-byte units), with byte offsets in decimal format
Display file in hexadecimal format (1-byte units), and 4 bytes per line
Display file in hexadecimal format along with its character representation, and do not print byte offsets
Read only 100 bytes of a file starting from the 500th byte
SYNOPSIS
od [OPTION]... [FILE]...
PARAMETERS
-A, --address-radix=RADIX
Select the base for the address display; RADIX can be d (decimal), o (octal, default), x (hexadecimal), or n (none).
-j, --skip-bytes=BYTES
Skip BYTES input bytes before formatting and writing.
-N, --read-bytes=BYTES
Limit dump to BYTES input bytes.
-t, --format=TYPE
Select output type or types; TYPE is a string of type specifiers: a, c, d, f, o, u, x, and additionally z. Append a size specifier to each type specifier. c and a are character types, d, o, u and x are integer types, f are floating point types.
-v, --output-duplicates
Output all input data, including duplicate lines.
-w, --width=BYTES
Output BYTES bytes per output line.
--traditional
Accept arguments in third tradition. (first in 7). Check man for detailed difference from other options
-h, --help
Display this help and exit.
-V, --version
Output version information and exit.
DESCRIPTION
The od command is a utility in Unix-like operating systems used to dump the contents of a file in various formats, primarily octal, but also hexadecimal, decimal, and ASCII. It's invaluable for inspecting binary files, troubleshooting data corruption, and understanding file structures when standard text editors are insufficient.
od allows you to control the byte order, address base, and the number of bytes displayed per line. This makes it a versatile tool for low-level analysis and debugging. Common uses include examining compiled code, verifying data integrity, and analyzing network packets saved to files. The command reads from standard input if no file is specified.
CAVEATS
od can produce a lot of output, especially for large files. Consider using the '-N' option to limit the amount of data displayed. Interpretation of the output requires a good understanding of data formats and byte ordering.
TYPE SPECIFIERS
The '-t' option allows for specifying the data type for output. Common types include:
a: Named character,
c: ASCII character or backslash escapes,
d: Signed decimal,
f: Floating point,
o: Octal,
u: Unsigned decimal,
x: Hexadecimal,
z: Display only printable characters.
BYTE ORDER
od displays data according to the machine's native byte order (endianness). This can be important when interpreting data from different systems or file formats.
HISTORY
The od command is a standard utility in Unix-like operating systems, dating back to the early days of Unix. It has been a crucial tool for developers and system administrators for inspecting and debugging binary files. Its usage has remained relatively consistent over the years, with minor enhancements to improve its flexibility and output formatting.