Can vi edit binary file in hex format?

othermark atkin901 at yahoo.com
Wed Jul 9 08:47:51 PDT 2003


Supote Leelasupphakorn wrote:
>    Is there option that enable standard vi (accompany wiht FreeBSD)
> for editing binary file in hex format ?

I do this fairly regularly, just use xxd.  For example try this:

cp /bin/cat ~/mycat
vi ~/mycat
<now editing in vi>
[esc] :%!xxd 
<now editing mycat in hex>
<find some innocuous string or rcsid>
<change the values on the hex side>
[esc] :%!xxd -r
[esc] :wq!
./mycat <somefile>

You can also 'pre' xxd transform the file, then edit it, then transform
it back when finished.

---
Mark
atkin901 at NOSPAM yahoo dot com
(!wired)?(coffee++):(wired);



More information about the freebsd-questions mailing list