I want to take a string like this:
Example string 59^!#&$(
And turn it into this:
\E\x\a\m\p\l\e\ \s\t\r\i\n\g\ \5\9\^\!\#\&\$\(
I've tried:
sed -e 's/./\\&/g; 1{$s/^$/""/}; 1!s/^/"/; $!s/$/"/'
as noted here:
But as noted by dalelane in a comment, this does not work under vanilla installation of bash in macOS. I have confirmed this with macOS High Sierra.
Any suggestions?
Best Answer
This works for me with bsd sed-
and with your string