Solved

vim xxd add/remove bytes

Posted on 2013-01-24
3
833 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
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

948 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

21 Experts available now in Live!

Get 1:1 Help Now