Start with a byte view
A configuration can look right in an editor and still contain an extra carriage return, a zero byte, or a missing final newline. The question is not initially what the file means. It is what bytes are present. The standalone utility od reads files and writes a representation of their contents to standard output, normally your terminal. It does not edit the input. We will use that representation to locate invisible bytes, inspect a bounded region, and interpret a supplied header without pretending to validate an entire file format.
These examples use GNU Coreutils od 9.4 and Bash 5.2.21 on Linux. Run them in order in one disposable shell session. The setup creates od-lab and config.bin. If od-lab already exists, choose another name. mkdir creates the directory, cd enters it, and && runs the next command only if the previous one succeeded; every setup step is guarded. export LC_ALL=C sets the C locale for this session and its child commands, making the character display and diagnostics predictable. This does not convert the file's encoding.
Bash's printf writes the quoted format: ordinary letters copy literally, \r inserts a carriage return, \n a line feed, and \0 a NUL byte with value zero. Single quotes protect the backslashes from the shell so printf interprets them. The shell's > creates or replaces the named output file. There is deliberately no final newline after tail. The earlier printf article develops this distinction between a trusted format and the data it prints.
In od, -A selects the address radix, the number base for byte-offset labels; x means hexadecimal, or base 16, using digits 0–9 and a–f. Independently, -t selects the data format. Its x1 argument means hexadecimal values in one-byte units. config.bin is the input filename. Specifying both choices avoids GNU od's default octal addresses and octal groups sized like the implementation's C short integer.
mkdir od-lab &&
cd od-lab &&
export LC_ALL=C &&
printf 'mode=prod\r\nkey=ok\0tail' > config.bin &&
od -A x -t x1 config.bin000000 6d 6f 64 65 3d 70 72 6f 64 0d 0a 6b 65 79 3d 6f
000010 6b 00 74 61 69 6c
000016Each pair after an address is one byte. The second row begins at hexadecimal 10, decimal 16, not at the file's second text line. The final address 16 is hexadecimal for decimal 22: the offset immediately after the last represented byte. It is a display label, not a stored trailer. Od's output has newlines for readability; those do not add newline bytes to config.bin.
Give invisible bytes readable names
Hexadecimal preserves the byte values, but familiar letters help explain them. The -A n argument suppresses address labels. The format c under -t shows printable single-byte characters, backslash escapes for selected controls, and three-digit octal numbers for other nonprinting bytes in this GNU implementation. Octal is base 8, using digits 0–7. The format a instead shows named characters from the seven-bit ASCII-compatible character set. Here ASCII means the familiar mapping of basic Latin letters, punctuation, and control characters to values 0–127.
Both commands read the unchanged config.bin. The second command's rows follow the first command's rows directly in this transcript.
od -A n -t c config.bin
od -A n -t a config.bin m o d e = p r o d \r \n k e y = o
k \0 t a i l
m o d e = p r o d cr nl k e y = o
k nul t a i lThe CR/LF pair appears as \r \n or cr nl. NUL appears as \0 or nul; it is neither a newline nor an end-of-input marker for od. The two characters backslash and n in this display represent one newline byte in the file. Nothing here proves which controls the application's configuration parser accepts. The GNU manual's c format is a single-byte view; it is not a general Unicode decoder.
A friendly view can discard a bit
The a format has an important limit: it ignores the high-order bit, the bit worth 128 in an eight-bit byte. Do not use it alone to establish byte equality. Create a two-byte supplementary fixture. In printf's format, \101 and \301 are octal byte escapes, decimal 65 and 193 respectively, or hexadecimal 41 and c1. No newline is appended.
Repeating -t asks od to render each input block in both formats, in the order supplied. It does not run the file through the first transformation and then the second. These are od type strings, not printf format strings: no percent signs are needed.
printf '\101\301' > high.bin
od -A n -t a -t x1 high.bin A A
41 c1The named view makes both bytes look like A. The hexadecimal view preserves the difference. This is why an x1 view should remain the reference when a readable rendering is only an aid.
Select a region without changing its address
Suppose a supplied incident note points to the configuration value starting at byte offset 11, counting from zero. The -j option skips that many bytes before formatting. The -N option limits the dump to at most its argument's number of input bytes after the skip. Here 11 and 6 are decimal arguments; changing -A does not change how they are interpreted. The -A d argument prints decimal addresses instead of hexadecimal ones.
The two commands inspect the same six bytes. GNU and POSIX interpret a leading 0x in these count arguments as hexadecimal and an otherwise leading 0 as octal; plain 11 avoids both conventions. This is an option argument rule, separate from the address display radix.
od -A d -j 11 -N 6 -t x1 config.bin
od -A x -j 11 -N 6 -t x1 config.bin0000011 6b 65 79 3d 6f 6b
0000017
00000b 6b 65 79 3d 6f 6b
000011Both windows contain key=ok. Addresses remain positions in the input: decimal 11 is hexadecimal b, and the end offset decimal 17 is hexadecimal 11. The next byte, NUL at decimal offset 17, is outside this selection. A clean window does not establish a clean whole file. Unlike cut's per-record selection, which can add a missing record terminator, this is a whole-stream byte view. Od still writes a representation, not an exact binary copy of the selected bytes.
Do not mistake repeated rows for missing data
Now create repeat.bin containing three adjacent copies of the eight characters 12345678, with no newlines. GNU's -w8 option sets the output width to eight input bytes per row. The 8 is attached to -w deliberately. Width controls display grouping, not a line or record boundary in the source. Without -w, GNU od normally groups 16 input bytes per row; -w with no number instead requests 32. For multibyte numeric formats, the width must be a multiple of all the selected unit sizes.
The first dump uses od's default suppression of repeated adjacent output groups. The -v flag in the second dump disables that suppression. The GNU manual and POSIX od specification document this as a presentation choice, not data removal from the input.
printf '123456781234567812345678' > repeat.bin
od -A d -t x1 -w8 repeat.bin
od -A d -t x1 -w8 -v repeat.bin0000000 31 32 33 34 35 36 37 38
*
0000024
0000000 31 32 33 34 35 36 37 38
0000008 31 32 33 34 35 36 37 38
0000016 31 32 33 34 35 36 37 38
0000024The asterisk is not byte 2a from the file. It abbreviates repeated rows; the final address still accounts for all 24 input bytes. Use -v when an evidence attachment or later comparison needs every row visible. This is display completeness, not an integrity guarantee.
Interpret a declared field, not a guessed format
A byte dump becomes a numeric interpretation only after you supply a layout. Our synthetic header is exactly eight bytes: the four-byte ASCII tag LAB1, followed by two unsigned two-byte integers. The declared order for those integers is big-endian: the most significant byte comes first. This is a teaching fixture, not an existing file format. printf's \001 through \004 escapes write bytes with values 1 through 4, not printable digits.
The u2 type means unsigned decimal integers assembled from two input bytes each. GNU's --endian=big explicitly applies big-endian interpretation to each numeric unit; --endian=little applies the opposite order, with the least significant byte first. Neither edits the file, and byte order has no effect on x1's one-byte units. Without an explicit byte-order option, multibyte numeric output follows the host implementation's native convention, not a convention discovered in the file.
The first command skips the declared four-byte tag and shows the four field bytes in both x1 and u2. The second changes only the interpretation of those same bytes.
printf 'LAB1\001\002\003\004' > header.bin
od -A d -j 4 -N 4 -t x1 -t u2 --endian=big header.bin
od -A d -j 4 -N 4 -t u2 --endian=little header.bin0000004 01 02 03 04
258 772
0000008
0000004 513 1027
0000008Big-endian 01 02 is 1 × 256 + 2 = 258; little-endian makes it 2 × 256 + 1 = 513. The format changes the question, not the bytes. The other numeric type letters are d for signed decimal, o for octal, x for hexadecimal, and f for floating point. A numeric size suffix specifies input bytes per value, subject to implementation support; omitting it chooses an implementation-sized type. A floating-point display additionally assumes a compatible representation. Od does not infer field boundaries, validate a signature, check a checksum, or establish that the supplied artifact is safe to open in another program.
A partial number can contain display padding
Limit the same region to three bytes, stopping halfway through its second declared two-byte field. The x2 type renders two-byte values in hexadecimal. The POSIX specification requires a partial final numeric unit to be extended with zero bytes for formatting. That extension is a representation artifact, not an observation that the input contained those extra bytes.
od -A d -j 4 -N 3 -t x1 -t x2 --endian=big header.bin0000004 01 02 03
0102 0300
0000007The x1 row shows exactly three selected bytes. The x2 row displays 0300 because it pads the incomplete unit; the actual fourth field byte, 04, was excluded by -N 3. The final offset is 7, not 8. When a supplied header appears truncated, inspect byte units and verify its length before treating a padded number as a complete field value.
Byte limits can divide a character
Create stream.bin with A, NUL, B, newline, and the known UTF-8 encoding of é. The octal escapes \303\251 write hexadecimal c3 a9, the two bytes of that character. This exact fixture is known to use UTF-8; od is not detecting its encoding. As the wc article explains, byte counts and character counts are different measurements: one character can require more than one byte.
First inspect the complete stream. Then skip its first four bytes and select just one byte. The -v flag retains every row, although this tiny input has no repeated rows to suppress.
printf 'A\0B\n\303\251' > stream.bin
od -A n -t x1 -v stream.bin
od -A n -t x1 -j 4 -N 1 stream.bin 41 00 42 0a c3 a9
c3Newline 0a and NUL 00 are ordinary bytes to this dump, not boundaries that reset its offsets. The final c3 alone is not a complete UTF-8 character. A byte window need not preserve characters, records, or declared fields. Keep the C-locale byte representation distinct from how a different locale or implementation might display multibyte text.
The same model works on standard input
Without a filename, od reads standard input. The shell's | operator connects the standard output of the command on its left to the standard input of the command on its right. Here printf supplies the same six bytes directly, without a temporary file. GNU also accepts a filename operand of - to mean standard input, but omitting filenames is the portable form used here.
The remaining commands create left.bin and right.bin with one byte each. Multiple input files are treated as a concatenated stream in operand order, with cumulative addresses; od does not insert a separator or print a filename label between them.
printf 'A\0B\n\303\251' | od -A n -t x1 -v
printf 'L' > left.bin
printf 'R' > right.bin
od -A d -t x1 left.bin right.bin 41 00 42 0a c3 a9
0000000 4c 52
0000002The pipe transports NUL directly; Bash variables cannot hold NUL bytes, so do not store arbitrary binary input in one before dumping it. Concatenation also means a multibyte numeric unit can span two files. A bounded -N dump does not promise that an upstream producer successfully completed, or that the pipeline consumed exactly that many bytes from every layer. In ordinary Bash without pipefail enabled, a pipeline's status is the last command's status. Producer health is a separate check from od's formatting success.
Retain the view without replacing the evidence
For an authorized inspection, retain a small attributable dump alongside the supplied original. This command reads config.bin and creates or replaces config.hex with its complete hexadecimal representation. Do not redirect a dump back onto its own input path: the shell can truncate that file before od reads it. Reports can expose secrets just as originals can; keep real reports under the same access controls as their source data.
The shell parameter $? expands to the immediately preceding command's exit status. Double quotes allow that expansion while keeping the resulting value in one argument. Printf's %s inserts that argument, and \n terminates the status line. Read the status immediately, before another command replaces it. Finally, cat copies config.hex to the terminal for inspection.
od -A x -t x1 -v config.bin > config.hex
printf 'dump status=%s\n' "$?"
cat config.hexdump status=0
000000 6d 6f 64 65 3d 70 72 6f 64 0d 0a 6b 65 79 3d 6f
000010 6b 00 74 61 69 6c
000016Od returns zero for success and nonzero for failure. The report retains addresses and repeated rows, but it is derived text, not the original binary evidence, a cryptographic hash, or a chain-of-custody record. Record the source identity, command, implementation, and acquisition context separately when they matter. Od leaves input contents unchanged; normal filesystem access metadata may still be affected by reading.
Success does not certify an expected length
The distinction matters most when a supplier claims a header should contain more bytes. POSIX and GNU define -N as a maximum, not an assertion that the input must be that long. Request 99 bytes from the eight-byte header, then compare that successful short read with an attempt to open a nonexistent file. missing.bin must remain absent in this disposable directory.
The shell's 2> redirects standard error, the diagnostic channel, into missing.err, creating or replacing it. Standard output remains separate. The last cat displays the retained diagnostic after its status line. The exact failure number and English diagnostic shown are observations from GNU 9.4 in the C locale; portable scripts should rely on zero versus nonzero, not this wording or a universal value of 1.
od -A d -t x1 -N 99 header.bin
printf 'short input status=%s\n' "$?"
od -A d -t x1 missing.bin 2> missing.err
printf 'missing input status=%s\n' "$?"
cat missing.err0000000 4c 41 42 31 01 02 03 04
0000008
short input status=0
missing input status=1
od: missing.bin: No such file or directoryStatus zero says the available eight bytes were processed successfully; it does not say 99 existed. Conversely, skipping beyond the available input with -j is an error. Check expected length separately and keep diagnostics when a dump is incomplete. A failure can leave partial output, so do not equate the existence of a report file with a completed inspection.
Keep the portable core explicit
POSIX specifies -A, -j, -N, -t, and -v. The -w width option and --endian byte-order control used here are GNU extensions to that interface; do not assume their availability or spelling on BSD, BusyBox, or uutils implementations. Exact spacing, address padding, and character rendering can differ. The examples deliberately use explicit byte units and a C locale, rather than depending on a machine's default integer size or Unicode display behavior.
For an unfamiliar supplied artifact, start with x1, meaningful addresses, and a bounded region. Add a readable view to explain controls, -v when repeated rows must remain visible, and a numeric view only after establishing the field layout and byte order. The valuable result is a defensible statement about the bytes you inspected—not a stronger story inferred from how those bytes happened to look.