Re: edit a binary file

From: Bill Thompson (bill.thompson@GOODYEAR.COM)
Date: Tue Sep 09 2003 - 15:38:49 EDT


Okay, nobody else bit on this so I'll give you *a* way to do it (probably
not the only way).

I have vim (http://www.vim.org) installed on all my computers. vim has a -b
option to allow you to directly edit binary files. Using vim with the -b
option in a "here to" notation would allow you to edit the file with a
script.

e.g.: Suppose you knew you wanted to change the characters at position
25-29 on line 5 of a binary file with the string "abcde". The following
script would do that.

#!/bin/sh
/usr/local/bin/vim -b /foo/bar/file <<END_OF_VIM
5G25|Rabcde^[:wq!
END_OF_VIM

However as I'm sure you know, changing a binary file is *very* dangerous.
Change them at your own risk

Bill Thompson
Sr UNIX Systems Administrator
The Goodyear Tire & Rubber Co.

Contains Confidential and/or Proprietary Information
May Not Be Copied or Disseminated Without Express Consent of The Goodyear
Tire & Rubber Company.

AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2

 ----- Original Message -----
 From: Arthur Prince
 Newsgroups: bit.listserv.aix-l
 To: aix-l@Princeton.EDU
 Sent: Monday, September 08, 2003 6:57 AM
 Subject: edit a binary file

 I ned to be able to edit a binary file frfom a sheel script, i.e replace
 one string with another. Can awk or sed or anything do this on a binary
 file?

 Message sent via Totalise Webmail - http://www.totalise.co.uk/



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:11 EDT