Linux Command - xxd

xxd - create hexadecimal representation(hexdump) for a file. use it to view files in binary or hexadecimal.

Syntax

1
xxd [OPTIONS] inFile [outFile]

Options

Common Option Description
-b switch to bits(binary digits) dump.
-c cols format cols octets per line. Default 16
-p output in postscript continuous hexdump style. Also known as plain hexdump style
-r reverse operation. convert (or patch) hexdump into binary.

Examples

Create hexdump for a file and display

1
xxd file1

Create hexdump for a file and save it

1
xxd file1 file1hex

Display 10 columns octets per line

1
xxd -c 10 file1

Display in plain hexdump style

1
xxd -p file1 

Display in plain hexdump style

this will take the hexdump file and revert it into original binary file

1
xxd -r -p hexdump 

Create bits dump for a file and display

1
xxd -b file1

Reference