Skip to content
Advertisement

Unix -Delete even bytes from a file

I want to find and delete all even bytes from a file given in command line. Is there any command for this situation?

Advertisement

Answer

I think this does what you want. It dumps the file as continuous plain hex, then reads two bytes, saving them for later and then two more bytes. Then it outputs the bytes it saved and pipes the whole lot back into xxd to “reconstruct”:

JavaScript

So, if I dump a PNG image like this:

JavaScript

and then put that through my filter and display it again:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement