hexdump Command Examples

Hexdump is a command-line utility used to display the contents of a file or data stream in various formats, including ASCII, decimal, hexadecimal, and octal representations. It provides a way to inspect the binary data of files or input streams in a human-readable format, making it useful for analyzing file formats, examining data structures, and debugging.

Key features and functionalities of hexdump include:

  • Multiple Output Formats: Hexdump can display the contents of files or input streams in several different formats, including hexadecimal, ASCII, octal, and decimal representations. Users can specify the desired format using command-line options to view the data in the most suitable format for their needs.
  • Customizable Display: Hexdump allows users to customize the display of data by specifying options such as the number of bytes per line, the number of columns, and the format of the output. This flexibility enables users to tailor the output to their preferences and the requirements of their analysis.
  • Offset Display: Hexdump displays the byte offset of each line of output, making it easy to track the position of data within the file or input stream. This information helps users navigate large files and correlate the displayed data with its location in the file.
  • Filtering and Skipping: Hexdump provides options for filtering and skipping data based on byte ranges or patterns. Users can specify byte offsets to start and end the display, as well as patterns to skip or highlight specific data within the input.
  • Binary and Text Mode: Hexdump can operate in binary or text mode, allowing users to handle both binary and text files seamlessly. In text mode, non-printable characters are displayed as periods (‘.’) for clarity, while binary mode displays the raw byte values.
  • Integration with Other Tools: Hexdump can be integrated with other command-line utilities and scripts to perform complex data analysis tasks. By piping the output of hexdump to other tools, users can extract, manipulate, and process binary data efficiently.

hexdump Command Examples

1. Print the hexadecimal representation of a file, replacing duplicate lines by ‘*’:

# hexdump [path/to/file]

2. Display the input offset in hexadecimal and its ASCII representation in two columns:

# hexdump -C [path/to/file]

3. Display the hexadecimal representation of a file, but interpret only n bytes of the input:

# hexdump -C -n[number_of_bytes] [path/to/file]

4. Don’t replace duplicate lines with ‘*’:

# hexdump --no-squeezing [path/to/file]

Summary

Overall, hexdump is a versatile and powerful tool for inspecting and analyzing binary data on Unix-like operating systems. Whether used for debugging, reverse engineering, or forensic analysis, hexdump provides essential functionality for working with binary files and data streams effectively.

Related Post