简体   繁体   中英

How can I insert control character ^@ into a file using sed in Linux?

I am running below command on file xyz .

sed -i 's/abc \"/abc \^@\"/g' xyz

But I am not getting desired output.

If I manually typing ctrl + v + @ it is visible in vi editor as ^@ but not with above command output.

The character you are referring to is a null byte ( 0x00 ). In sed you need to use \\x00 for it:

sed 's/abc \"/abc \x00\"/' file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM