· 1 min read
xxd easy to use way record
# Dev Note 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
- Stop Using Access Keys AlreadyAccess 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 UUIDv7Backend 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.
- Sharing My Experience with ZeaburIndependent developers often choose platforms like Vercel for deploying their services. However, when more advanced requirements arise, such as database connections, Vercel can become less convenient. Additionally, the pricing of typical cloud service providers can be quite expensive for solo developers. In this article, I’ll share some insights on using Zeabur and highly recommend it to everyone!
- Keyboard Enthusiast's Guide - Firmware EditionThis article is part of the IT 2023 Ironman Competition: A Beginner's Guide to Keyboards - Firmware Edition.