I have a binary file and I would like to remove parts from. By removing I mean deleting those parts and thus making the file's size smaller.
The parts would be between two ASCII strings. So, for example the file would look like this
........ start ABCD end ..... start EFGH end ..... start IJKL end ...........
So in this file, I would like to search for strings "start" and "end" and remove the parts between them.
The way I think I can do it is to
- lookup all the locations for "start" and "end"
- calculate ranges from that
- delete those parts
Now I am using some GUI based Hex editor and I use the "Search All", "Select Range" and "Delete" commands, but I am sure it would be possible to solve it using some powerful command line hex/text editors.
Do you know any solution for this problem which doesn't require using a GUI for looking up, copy & paste on clipboard, select range and delete commands but is just a few lines of command line?
I am interested ini both Linux shell scripts or using some command line hex editors under Windows, or even Python scrips are welcome.
Do you think it is possible to solve this problem just by a simple Regex replace? Are there any regex replace util which handles binary files well?