In bash, I have a string containing \n
characters. When I echo -e $mystring
it formats as I expect in the console, respecting the newline characters. However, when I redirect the output to a file, the resulting file is all one line, minus the \n
characters, even if I use the -e
flag:
echo -e $mystring > myfile.txt
However, tabs \t
are respected. How can I get the formatting right in the file?