Solved

vim xxd add/remove bytes

Posted on 2013-01-24
3
814 Views
Last Modified: 2013-02-11
Before I give up on vim/xxd as my hex editor of choice, does anyone here know of a reliable way to add or remove bytes from a file? Most of the time, if I try to add anything that changes the length of the file, it blows up pretty badly. The way xxd actually uses the offsets, it seems unlikely. (Adding and removing at the end isn't too tough).

I wrote a small executable that does just about the same thing as xxd except it lets you change the file size; but before I bother making it more robust, I thought I'd make sure xxd can't do what I want.
0
Comment
Question by:TommySzalapski
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
Comment Utility
Yes, the offsets are going to break it every time.  I think the only way is to use the -p option to do a plain hexdump, though that does lose the useful ASCII representation.

Or add an "ignore offset" option to "xxd -r"!
0
 
LVL 37

Author Comment

by:TommySzalapski
Comment Utility
Hah, that's true. I could just modify xxd. It's probably faster to write my own though since it's such a simple thing. I'll have to check the -p option Monday and see if that does the trick.
0
 
LVL 37

Author Comment

by:TommySzalapski
Comment Utility
Oops. Forgot I had this out there. Haven't needed hex editing in a while.

Adding the -p does fix it. It does make it lots harder to read though, so I'll keep my little app around for personal use. Thanks for the tip.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now