cat command prints the contents of a file to the terminal (console). $ cat «FILENAME» When used in this manner, it is primarily useful for human-readable files (i.e., text files). xxd command shows you the individual bytes in a file, in hex (default) or binary bits (if selected) format. Use it to troubleshoot. To view the bytes in hex format: (don't type the '$') $ xxd -g1 «FILENAME» To view the bytes in binary format: (don't type the '$') $ xxd -g1 -b «FILENAME» To view the options for xxd: $ xxd --help To view the full man page (documentation) for xxd: $ man xxd xxd is the best choice for "binary files" (not meant for human reading). Binary files may contain bytes with value ≥127 and/or <32. __________________________________________________ REMEMBERING VALUES Dec Hex Binary 0 0 0 easy 1 1 1 easy 2 2 10 power of 2 3 3 11 4 4 100 power of 2 5 5 101 (picture?) 6 6 110 7 7 111 one less than a power of 2 are all 1s 8 8 1000 power of 2 9 9 1001 10 a 1010 "ten ten" 11 b 1011 "│₀\\" -OR_ "ten eleven" 12 c 1100 (picture) 13 d 1101 (picture) 14 e 1110 (picture) 15 f 1111 one less than a power of 2 ⇒ all 1s "C" /⁰ » /\⁰₀ » 1100 \₀ __________________________________________________ HEX IN CONSTANTS / LITERALS character constant (character literal) 'C' '\x43' // '\x▒▒' for character literal using hex notation string literal "C" "\x43" // "\x▒▒" for string literal using hex notation integer constant (integer literal) 67 0x43 // 0x▒▒ for integer literal using hex notation __________________________________________________ HOW TO CREATE TEST INPUT FILES FOR TESTING Create a text file containing exactly three bytes. $ echo -e -n '\xdb\xacC' > dbacC.txt -e means to interpret C-style escapes. -n means to NOT add a newline at the end. Better yet, use the method illustrated today.