Re: Null character in replacement

Andreas Schwab <[email protected]> Fri, 24 Oct 2014 15:13:27 +0200
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Zachary Vance <[email protected]> writes:

> sed -e "s/^$/\0/" (in bash, an s// expression containing a literal zero
> byte) performs no replacements on the stream.

A command line argument cannot contain a literal zero byte, since
argument strings are zero-terminated, and you would get an error about
an unterminated command.

$ sed -e $'s/^$/\0/'
sed: -e expression #1, char 5: unterminated `s' command

Andreas.

-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."