Show file hexadecimal format
hexdump command is generally used to view the hexadecimal encoding of "binary" files, but in fact it can view any file, not just binary files.
hexdump [options] [file]...
-n length Format only the first length bytes of the input file.
-C Output canonical hexadecimal and ASCII codes.
-b Single-byte octal display.
-c Single-byte character display.
-d Double-byte decimal display.
-o Double-byte octal display.
-x Two-byte hexadecimal display.
-s Start output at offset.
-e specifies the format string. The format string is contained in a pair of single quotes. The format string is in the form: 'a/b "format1" "format2"'.
Each format string consists of three parts, each separated by spaces. The first one is in the form a/b, where b means to apply format1 format to each b input bytes, and a means to apply format2 format to each a input bytes. , generally a>b, and b can only be 1, 2, 4. In addition, a can be omitted, if omitted, a=1. Format strings similar to printf can be used in format1 and format2, such as:
%02d: two decimal places
%03x: three digits of hexadecimal
%02o: two-digit octal
%c: single character, etc.
There are also some special uses:
%_ad: Marks the sequence number of the next output byte, expressed in decimal.
%_ax: Marks the sequence number of the next output byte, expressed in hexadecimal.
%_ao: Marks the sequence number of the next output byte, expressed in octal.
%_p: Use . to replace characters that cannot be displayed as regular characters.
If you want to display multiple format strings on the same line, you can follow multiple -e
options.
hexdump -e '16/1 "%02X " " | "' -e '16/1 "%_p" "\n"' test
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | ............
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F | ............
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./