i have a simple shell script that echoes variable in a file but i have issues getting it work the same way between the different distributions.
The script
#!/bin/sh
res="=1B,\=AB=D2=DB=B5=A6e=FCj=10=0C=EE=91@y\e=082 ="
echo $res
The the result in Ubuntu 20.04.3
=1B,\=AB=D2=DB=B5=A6e=FCj=10=0C=EE=91@y082 =
And result in CentOS 6.0
=1B,\=AB=D2=DB=B5=A6e=FCj=10=0C=EE=91@y\e=082 =
Why Ubuntu is not printing the "\e" and how to make it print it?
-e
flag – steeldriver Jan 14 '22 at 12:43printf "%s\n" "$res" > /path/to/file
– steeldriver Jan 14 '22 at 12:52/bin/sh
in Ubuntu is Dash by default, CentOS probably has Bash. And their implementations ofecho
differ in how they treat backslash escapes. Bash only processes them with-e
, and Dash doesn't seem to have a way to disable it. – ilkkachu Jan 14 '22 at 13:52