I would like to output results in latex table format using a bash script. However, when I want to add a newline symbol, bash either prints it (\n) or doesn't add a newline. I already tried several things (e.g. the ones mentioned https://superuser.com/questions/154936/echo-text-with-new-line-in-bash), but nothing seems to work. What am I doing wrong?
echo "$(cat $outputFile)$latexString" > $outputFile echo "\\\\" >> $outputFile echo "" >> $outputFile
$latexString is the line of the table I want to save,
\\ is the EOF for the line in the table, and after that I want to have a newline.
EDIT The output file should look like:
res1 & 1 & 2 & 3 & 4 \\ res2 & 5 & 6 & 7 & 8 \\ ...
'latexString' is then e.g.,
res1 & 1 & 2 & 3 & 4
\nto your LaTeX file? Isn't
\\already the "newline symbol" in LaTeX?
\\` at the end of the line. So it cannot print\n`, but needs to put the content on separate lines instead.
$latexStringis. There might be better way of approaching this.
echo "$(cat $outputFile)$latexString" > $outputFile, do you mean
echo "$latexString" >> $outputFile?
$outputFile. Why aren't you using