如何在 Linux 中使用 sed 将控制字符 ^@ 插入到文件中?

sab*_*ber 1 linux shell sed

我在文件上运行以下命令xyz

sed -i 's/abc \"/abc \^@\"/g' xyz
Run Code Online (Sandbox Code Playgroud)

但我没有得到想要的输出。

如果我手动输入ctrl+ v+@它在 vi 编辑器中可见,^@但在上面的命令输出中不可见。

hek*_*mgl 5

您所指的字符是空字节 ( 0x00)。在 sed 中,您需要使用\x00它:

sed 's/abc \"/abc \x00\"/' file
Run Code Online (Sandbox Code Playgroud)