· 1 min read
xxd easy to use way record
This article was auto-translated from Chinese. Some nuances may be lost in translation.
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
xxd filename | vim -: View the binary file usingvim- Open
vim filenameand then within it type:%!xxd -rto edit the binary file using vim xxd filename > dump.hex: Save the output directly to a file, which can be used withdifffor comparison
Related Posts
- When Measurement Becomes the Goal: From Window Tax to PR Counts I once wrote a small tool to count how many PRs I had contributed in a quarter, how many reviews I had left, and how many tickets I had closed, hoping to use the numbers to prove my output to my manager. My manager simply said performance is not judged by output alone. Only years later did I understand—when measurement becomes the goal, it is no longer a good measure. From Britain’s window tax and the Hanoi rat bounty to evaluating developers by PR count today, the mechanism is exactly the same.
- Using Cloudflare Images for Image Storage and Transformation Putting an image on a web page is the easiest thing in frontend. But doing it properly — resizing, generating every format, holding up under traffic — turns into a whole solution of its own. I ended up handing all of it to Cloudflare Images and keeping just one original.
- Stop Using Access Keys Already Access Keys are an easily overlooked security risk on AWS. Use OIDC with IAM Roles so GitHub Actions can securely access AWS resources without any secrets.
- Database Primary Keys: AUTO_INCREMENT, UUID, and UUIDv7 Backend developers often have to decide on a primary key: auto increment or UUID? What about collisions? How much faster is UUIDv7 compared with created_at + index? After benchmarking 20 million rows and looking at the design trade-offs, this post gives you the answer.