Skip to Content
gnux

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 -t x1 or -t x2.
  • Checking a file's byte order or a magic number with --endian and -N.
  • Decoding integers or floating-point values stored in a binary file.
  • Getting a hexdump-style view with -A x -t x1z.
  • Extracting printable strings from a binary with -S.
  • Dumping just a slice of a large file with -j and -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 line

Examples

Dump a file as octal words

odx data.bin

Show every character, with escapes for invisible ones

odx -c notes.txt

A hexdump with offsets in hex and the text alongside

odx -A x -t x1z image.png

A 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.yaml

Read the first four bytes (a magic number)

odx -A n -t x1 -N 4 image.png

Skip a 512-byte header and dump the next 64 bytes

odx -j 512 -N 64 -t x1 disk.img

Decode big-endian 32-bit integers

odx --endian=big -t u4 counts.bin

Decode floating-point values

odx -t f8 samples.bin

Two formats per line, hex bytes over characters

odx -t x1 -t c file.txt

Look for Windows line endings in standard input

printfx 'a\r\nb\n' | odx -c
odx -v -t x1 zeros.bin

Eight bytes per line

odx -w8 -t x1 data.bin

List the printable strings of at least 6 characters in a binary

odx -S 6 program.bin

Options

Each option has a page of its own, with its usage and examples.

Exit status

StatusMeaning
0success: every operand was processed
1failure: 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

See also

On this page