Home > OS >  Use SED to fix new lines
Use SED to fix new lines

Time:06-07

I have a utf-16 file where each new line somehow have been replaced by 0x00 0x00 0x0A. This make the file completely corrupt, and I try to use the sed command to replace this sequence with 0x00 0x0A.

I have try to use following sed command, but it don't work. What am I doing wrong?

sed -i.bak 's/\x0\x0\0x0A/\x0\x0A/g' "test.h"

CodePudding user response:

You don't need to match \x0A as that is is \n, which can be matched using $.

Following should work in gnu-sed:

sed -i.bak 's/\x0\x0$/\x0/' test.h
  • Related