Solved

vim xxd add/remove bytes

Posted on 2013-01-24
3
985 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 38817930
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
ID: 38820906
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
ID: 38876786
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.
Suggested Courses

624 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