I'm want to replace some bytes in binary file to another. Created sample (6 bytes long) file via
echo -ne '\x8f\x15\x42\x02\x24\xc2' > test
Then tried to replace bytes \x15\x42\x02 to \x12\x12\x02 via sed:
sed 's \x15\x42\x02 \x12\x12\x02 g' test > test1
sed replaced bytes:
cat test test1 | xxd -c 6
0000000: 8f15 4202 24c2 ..B.$.
0000006: 8f12 1202 24c2 ....$.
^^ ^^^^
Tried then replace bytes \x42\x02\x24 to \x12\x02\x24:
sed 's \x42\x02\x24 \x12\x02\x24 g' test > test2
sed NOT replaced bytes:
cat test test2 | xxd -c 6
0000000: 8f15 4202 24c2 ..B.$.
0000006: 8f15 4202 24c2 ..B.$.
^^^^ ^^
What's wrong? I have sed (GNU sed) 4.2.2 (Kubuntu 13.10)
Thank You.