How to overwrite some bytes of a binary file with dd?

Wei Shi picture Wei Shi · Sep 3, 2011 · Viewed 18.2k times · Source

I have a binary file and i want to replace the value A2 at address DEADBEEF with some other value, say A1.

How can I do this with dd? If there are other tools that can do this, please suggest. But I plan to do this on iPhone so I can only work with most basic Unix tools.

Answer

Chris Jester-Young picture Chris Jester-Young · Sep 3, 2011
printf '\xa1' | dd conv=notrunc of=somefile bs=1 seek=$((0xdeadbeef))