Using just shell tools, how can a binary stream containing NULLs (0x00 chars) be edited keeping the 0x00 chars in the output stream ?
The edit needs to replace a char in a specified position for another char (in the following example by the char '|'), like as:
dd ibs=1 skip=$offset count=$reglen status=none if=$ARQ |
sed 's/./\|/2' |
sed 's/./\|/5' #| more replacements....
But sed is removing all '\0x00' chars before the replacement.
EDIT - Demonstration of sed behavior in my environment using the @George Vasiliou test:
$ echo -e "lineA\nlineB\nlineC" | tr '\n' '\0' | od -t x1
0000000 6c 69 6e 65 41 00 6c 69 6e 65 42 00 6c 69 6e 65
0000020 43 00
0000022
$ echo -e "lineA\nlineB\nlineC" | tr '\n' '\0' | sed 's/./|/5' | od -t x1
0000000 6c 69 6e 65 7c 6c 69 6e 65 42 6c 69 6e 65 43
0000017
My environment is an AIX 7.1 and the sed that is there isn't the gnu version.