logo
  • 現在做什麼
  • 關於我

Kalan

文章分類

  • 前端
  • 開發筆記
  • 雜談
  • 年度回顧

快速連結

  • 現在做什麼
  • 關於我
  • 聯絡我
  • 職涯思考🔗

關注我

在福岡生活的開發者,分享軟體開發與日本生活的點點滴滴。

© 2025 Kalan Made with ❤️. All rights reserved.

xxd easy to use way record

Written byKalanKalanMar 29, 2020
Home/Dev Note
💡

If you have any questions or feedback, pleasefill out this form

Japanese原文

Table of Contents

  1. Why Would You Want to Look at Binary Files?
  2. Using xxd
  3. Some Helpful Combinations

This post is translated by ChatGPT and originally written in Mandarin, so there may be some inaccuracies or mistakes.

xxd is a Linux tool that allows you to view binary files.

Why Would You Want to Look at Binary Files?

  • To check if the compiled program matches your expectations
  • To inspect the content of image or video files
  • Pure curiosity

Using xxd

xxd filename

This command will output the file content like this:

00000000: 4500 6d00 7000 7400 7900 0000 0000 0000  E.m.p.t.y.......
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................

The output can be divided into three sections: the first is the hex dump address, with each line dumping 16 characters (by default), the second is the file content (displayed in ASCII encoding), and the far right shows the raw values of the file. If there are any unprintable characters, they will be represented by a ..

xxd -r filename

This command can revert the binary file back to its original form.

Some Helpful Combinations

  1. xxd filename | vim -: View the binary file using vim
  2. Open vim filename and then within it type :%!xxd -r to edit the binary file using vim
  3. xxd filename > dump.hex: Save the output directly to a file, which can be used with diff for comparison
← Rise of Creators - ProgrammingPips are still Important/idea still count →

If you found this article helpful, please consider buying me a coffee ☕ It'll make my ordinary day shine ✨

☕Buy me a coffee

Table of Contents

  1. Why Would You Want to Look at Binary Files?
  2. Using xxd
  3. Some Helpful Combinations