Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jul 2003 15:45:22 +0000 (UTC)
From:      othermark <atkin901@yahoo.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Can vi edit binary file in hex format?
Message-ID:  <slrnbgoe5v.12ab.atkin901@adkinson245.f5net.com>
References:  <20030709051536.68163.qmail@web40609.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?slrnbgoe5v.12ab.atkin901>