[NYLoCo] Bash Line Breaks

Jeffrey Knight jeffrey.knight at gmail.com
Fri Sep 14 18:34:13 BST 2007


Anyone know how to preserve line breaks in a multi-line string in bash?

string="hello here is a
string that runs across
several lines"

echo $string

>hello here is a string that runs across several lines
Where'd my line breaks go?

\n's and \r's don't seem to help ...

I thought maybe it was putting it into an array, but
echo ${string[0]}
gives me the same result.

Any ideas ?
-Jeff



More information about the Ubuntu-us-ny mailing list