[nzlug] Find and replace within a binary file?

Daniel Pittman daniel at rimspace.net
Thu Jul 3 13:01:05 NZST 2008


Simon <greminn at gmail.com> writes:

> Hi There, Im trying to compile a driver and have these instructions...
>
> Now copy lib/fcpci-lib.o to lib/f2pci-lib.o and replace all occurences
> of "fcpci" in
> f2pci-lib.o by "f2pci". (It's a binary file, so be careful)
> Replace all occurences of __fcpci__ in src.drv/* by __f2pci__. (quite many)
> In src.drv/defs.h, replace
>
> Im wondering if someone could assist me to do the find and replace for
> the binary file. Im ok with the rest of it :)

Easy:

  sed -e 's/fcpci/f2pci/g' < f2pci-lib.o > f2pci-hacked.o

sed will not mangle any of the characters on the way through, and can
trivially substitute only the string.

Regards,
        Daniel



More information about the NZLUG mailing list