Why must I enter "\\\0" to create a string "\0" in zsh? Why must I enter "\\\0" to create a string "\0" in zsh? unix unix

Why must I enter "\\\0" to create a string "\0" in zsh?


Use single quotes and turn off escape handling in echo with the -E flag.

echo -E '\0' should produce a \0 on both zsh and bash (and dash).


This is the standard (read portable) way to do it:

printf "\0"

Should work whatever the (Unix like) OS, whatever the shell.