Help with convert string

Hi.
I will be very appreciated for help.
I need replace all characters into string with \ (backslash)
I mean if I have word abcdefg as input.
How I can convert it to \a\b\c\d\e\f\g

Thanks and best regards. Staas.

echo "abcdefg" | sed 's/./\\\0/g'
1 Like
sed 's/./&\\/g' file

Hi
Thanks for quick answer
Staas.

With the command above I get this as output:

echo "abcdefg" | sed 's/./\\\0/g'
\0\0\0\0\0\0\0

Hmmm.. I guess \0 as substitute of "&" can be used only in GNU sed...