"Pascal Miquet"
I've got a binary file and I'd like to replace a pattern by another string. The SED command seems to do the job, but finaly the binary file seems to not be correct :(
Original sed has been designed to work with text files only. If you
don't know the internals of your sed implementation then I don't
recommend you use it for binary files.
Perl can do the job. Instead of
$ sed -e 's/A/B/g'
use
$ perl -p -e 's/A/B/g'
but it may read the whole binary file into memory. BTW: Emacs can also
be used.
It's also possible to convert the binary file into an ASCI file, use
sed and then convert it back to a binary file. I include a simple
example without any explanation:
bin2hex < file | sed -e '32s/0A/65/1' | hex2bin > new_file
$ cat bin2hex.c
#include