jip*_*pie 22
例子:
证明我正在发送一个 NUL 字节,后跟一个换行符:
$ echo -e \\0 | hexdump -C
00000000 00 0a |..|
00000002
Run Code Online (Sandbox Code Playgroud)
现在我将 NUL 字节更改为!感叹号:
$ echo -e \\0 | sed 's/\x00/!/' | hexdump -C
00000000 21 0a |!.|
Run Code Online (Sandbox Code Playgroud)
所以诀窍是使用\x00NUL 字节。
是的,模式\x00匹配空字节。
例子:
$ printf "\0\n\0\n" > file
$ sed -e 's/\x00/test/' -i file
$ cat file
test
test
$
Run Code Online (Sandbox Code Playgroud)