Solved

vim xxd add/remove bytes

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

840 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