Trying not to be a downer, but I wouldn't think of writing such a tool. I'd use Perl's pack or Python's struct.
Of course there might be some value in something less than a full language.
Of course there might be some value in something less than a full language.
Though reading both `pack` and `struct` the formats are about as obtuse as a regex. And the lack of individual bit support in `struct` is limiting.
Come to think of it, like other comments already, this could be a handy CLI streaming tool. Dealing with adjusting binary output on the CLI turns out to be a pain...