dumb question, but what would you use to "search and replace" a string (with a shorter one) in a binary file (size ~5GB).

And it is in there a few hundred thousand times. False positives are avoidable in this case.

Of the top of my head I only know hex editors that allow to replace bytes with equally long ones...

#Binary #Hex

Turns out if you've enough RAM the answer is python. You could probably do it also without reading the entire file into RAM first but I'm too lazy to optimise this further, 5GB fits easily into my RAM so...

```
old = b"Hello World"
new = b"World"

filename = "file.bin"

with open(filename, "rb") as f:
data = f.read()

data = data.replace(old, new)

with open(filename, "wb") as f:
f.write(data)

print("Done")
```