On Tuesday 02 December 2008 13:33, KLEIN Stéphane wrote: > Hi, > > I need to update one octet in a binary file (it's disk image file > raw). > > To do that, I use hexedit and I do update manualy. > > Now, I would like to script this task, I know address of octet to > update and the new value. > > Do you know a tool to do that ? > [...]
Hi, this is an example. Suppose you have the original file "orig": $ hexdump -v -x orig 0000000 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000010 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000020 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000030 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000040 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000050 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000060 0e0e 0e0e 0000064 and you want to apply some arbitrary length patch at some point in the file. You have the following "patch" file, in this case 10 bytes: $ hexdump -v -x patch 0000000 7a7a 7a7a 7a7a 7a7a 7a7a 000000a Now, with this command we insert the content of "patch" in "orig" at byte 20: $ dd if=patch bs=1 conv=notrunc of=orig seek=20 count=10 10+0 records in 10+0 records out 10 bytes (10 B) copied, 7.8222e-05 seconds, 128 kB/s And here is the result: $ hexdump -v -x orig 0000000 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000010 0e0e 0e0e 7a7a 7a7a 7a7a 7a7a 7a7a 0e0e 0000020 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000030 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000040 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000050 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0000060 0e0e 0e0e 0000064 Best regards, alfredo -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]