Bash: Special characters lost when reading file

Viewed 19518

I have a file containing some Latex :

\begin{figure}[ht]
 \centering
 \includegraphics[scale=0.15]{logo.pdf}
 \caption{Example of a pdf file inclusion}
 \label{fig:pdfexample}
\end{figure}

I want to read it in a bash script :

while read line
  do
    echo $line
  done < "my.tex"

The output is

begin{figure}[ht]
centering
includegraphics[scale=0.15]{logo.pdf}
caption{Example of a pdf file inclusion}
label{fig:pdfexample}

Why did I lose the backslashes and initial spaces ?

How to preserve them ?

2 Answers
Related