Command line tools to replace bytes in a file I need to write a script that patches a few bytes at a particular offset in a binary file. I know of textual tools for this task (sed, though I find it utterly hard to use) but can't find one for binary patching. Are there any?

If not installed by default, anything I can install with Homebrew would be acceptable as well.
You can achieve it with dd command. Here's an example:

$ hexdump StringComparison  | head -1
0000000 cf fa ed fe 07 00 00 01 03 00 00 80 02 00 00 00

$ printf '\x11\x11\x11' | dd of=StringComparison bs=1 seek=4 count=3 conv=notrunc
3+0 records in
3+0 records out
3 bytes transferred in 0.000293 secs (10238 bytes/sec)

$ hexdump StringComparison  | head -1
0000000 cf fa ed fe 11 11 11 01 03 00 00 80 02 00 00 00


Explanation:


of = input file
bs = block size
seek = position (offset)
notrunc = do not truncate the output.