odx
Dump files in octal and other formats.
Mirrors GNU od. Run it as odx, or as gnux odx.
Synopsis
odx [OPTION]... [FILE]...GNU reference
Description
odx writes an unambiguous representation of its input, by default as two-byte octal words, sixteen bytes per line, each line starting with the input offset in octal. The FILEs are read one after another as one input; with no FILE, or when FILE is -, it reads standard input. -t TYPE selects the format and may be given more than once, each format getting a line of its own per block, in the order given: a (named characters), c (printable characters or backslash escapes), d, o, u and x (signed decimal, octal, unsigned decimal and hexadecimal) with an optional size in bytes (1, 2, 4, 8, or C, S, I, L), and f (floating point, size 4 or 8, or F, D, L); a trailing z adds the printable characters of the line between > and <. The traditional letters -a, -b, -c, -d, -f, -i, -l, -o, -s and -x are shorthands for -t a, o1, c, u2, fF, dI, dL, o2, d2 and x2. -A RADIX picks the offset base (d, o, x, or n for none), -j BYTES skips input, -N BYTES limits it, -w BYTES sets the bytes per line, and --endian chooses the byte order of multi-byte values. Unless -v is given, a run of lines identical to the one before is shown as a single '*'. -S N prints the NUL-terminated strings of at least N printable characters instead of a dump. BYTES may be decimal, octal with a leading 0, or hexadecimal with 0x, followed by a multiplier: b 512, k or K 1024, kB 1000, M, MB, G and so on. Differences from GNU od: characters are interpreted in the C locale, so -c shows every byte above 127 in octal; long double (fL) is read as an eight-byte double; -S and -w need a value (GNU's bare -S means -S3 and bare -w means -w32), because an optional value could not also be attached as in -w8; the traditional offset operand ([+]OFFSET[.][b]) and --traditional are not implemented.
gnux's terminal view (BR-13): on a terminal, each value is colored by the class of its bytes, so the structure of a binary file shows at a glance: zero bytes dimmed, printable ASCII, whitespace, other control characters and bytes above 0x7f each in a color of their own (a value of several bytes takes the most unusual class among them), and the same in the -t ...z trailer; the offsets and the '*' of a repeated block are dimmed. The text is GNU's. --pretty[=WHEN] and --theme=NAME, options of gnux's own, choose the view (GNUX_PRETTY, GNUX_THEME); piped or redirected output, and -S, are never colored.
Permissions
Needs read permission on each FILE and search permission on the directories leading to it. Nothing is ever modified.
Use cases
- Seeing exactly which bytes a file holds, including invisible ones.
- Finding stray carriage returns, tabs or NUL bytes with
-c. - Reading binary headers as hexadecimal bytes or words with
-tx1 or-tx2. - Checking a file's byte order or a magic number with
--endianand-N. - Decoding integers or floating-point values stored in a binary file.
- Getting a hexdump-style view with
-Ax-tx1z. - Extracting printable strings from a binary with
-S. - Dumping just a slice of a large file with
-jand-N.
Flags
-A, --address-radix RADIX output format for file offsets; RADIX is one of [doxn], for Decimal, Octal, Hex or None (default "o")
-c, --characters string[="true"] same as -t c, select printable characters or backslash escapes
-s, --decimal-2-bytes string[="true"] same as -t d2, select decimal 2-byte units
-i, --decimal-ints string[="true"] same as -t dI, select decimal ints
-l, --decimal-longs string[="true"] same as -t dL, select decimal longs
--endian ORDER swap input bytes according the specified ORDER: little or big
-f, --floats string[="true"] same as -t fF, select floats
-t, --format TYPE select output format or formats; TYPE is a, c, d, f, o, u or x with an optional size, and z
--help display this help and exit
-x, --hex-2-bytes string[="true"] same as -t x2, select hexadecimal 2-byte units
-a, --named-characters string[="true"] same as -t a, select named characters, ignoring high-order bit
-o, --octal-2-bytes string[="true"] same as -t o2, select octal 2-byte units
-b, --octal-bytes string[="true"] same as -t o1, select octal bytes
-v, --output-duplicates do not use * to mark line suppression
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
-N, --read-bytes BYTES limit dump to BYTES input bytes
-j, --skip-bytes BYTES skip BYTES input bytes first
-S, --strings BYTES show only NUL terminated strings of at least BYTES printable characters
--theme NAME color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
-d, --unsigned-decimal-2-bytes string[="true"] same as -t u2, select unsigned decimal 2-byte units
--version output version information and exit
-w, --width BYTES output BYTES bytes per output lineExamples
Dump a file as octal words
odx data.binShow every character, with escapes for invisible ones
odx -c notes.txtA hexdump with offsets in hex and the text alongside
odx -A x -t x1z image.pngA config file breaks a parser, but looks fine in an editor: find the stray carriage returns and the byte order mark, which the terminal view colors apart from the text
odx -A x -t x1z -N 64 config.yamlRead the first four bytes (a magic number)
odx -A n -t x1 -N 4 image.pngSkip a 512-byte header and dump the next 64 bytes
odx -j 512 -N 64 -t x1 disk.imgDecode big-endian 32-bit integers
odx --endian=big -t u4 counts.binDecode floating-point values
odx -t f8 samples.binTwo formats per line, hex bytes over characters
odx -t x1 -t c file.txtLook for Windows line endings in standard input
printfx 'a\r\nb\n' | odx -cPrint every line, even repeated ones
odx -v -t x1 zeros.binEight bytes per line
odx -w8 -t x1 data.binList the printable strings of at least 6 characters in a binary
odx -S 6 program.binOptions
Each option has a page of its own, with its usage and examples.
- -A, --address-radix: Output format for file offsets; RADIX is one of [doxn], for Decimal, Octal, Hex or None.
- -c, --characters: Same as
-tc, select printable characters or backslash escapes. - -s, --decimal-2-bytes: Same as
-td2, select decimal 2-byte units. - -i, --decimal-ints: Same as
-tdI, select decimal ints. - -l, --decimal-longs: Same as
-tdL, select decimal longs. - --endian: Swap input bytes according the specified ORDER: little or big.
- -f, --floats: Same as
-tfF, select floats. - -t, --format: Select output format or formats; TYPE is a, c, d, f, o, u or x with an optional size, and z.
- -x, --hex-2-bytes: Same as
-tx2, select hexadecimal 2-byte units. - -a, --named-characters: Same as
-ta, select named characters, ignoring high-order bit. - -o, --octal-2-bytes: Same as
-to2, select octal 2-byte units. - -b, --octal-bytes: Same as
-to1, select octal bytes. - -v, --output-duplicates: Do not use * to mark line suppression.
- --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default. - -N, --read-bytes: Limit dump to BYTES input bytes.
- -j, --skip-bytes: Skip BYTES input bytes first.
- -S, --strings: Show only NUL terminated strings of at least BYTES printable characters.
- --theme: Color the view with the built-in theme NAME (
gnuxtheme picks and saves one); GNUX_THEME sets the default. - -d, --unsigned-decimal-2-bytes: Same as
-tu2, select unsigned decimal 2-byte units. - -w, --width: Output BYTES bytes per output line.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
odx --help # options, first examples, exit status
gnux help odx # this page: the full manual
gnux help odx --OPTION # one option in depth, with its examples