This is my first attempt at linux shell scripts. Me being me, I don't start with "hello world."


What I want to do is call a program and pull out info from the stdout results. The first problem seem to be that the newlines are stripped out at some point.

This works:

#! /bin/ksh
MYVAR="Hello world\nThe world is round\nBaseballs are round\nThe world must be a baseball\nHello baseball"
echo -e ${MYVAR}

This does not:

#! /bin/ksh
MYVAR=$(ls -la)
echo -e ${MYVAR}


Funny thing is that if I use the -x option to debug, I can see the \n newlines in MYVAR in both tests but they don't print in the second.

I've been pulling my hair out for hours on this and cannot find anything on Google. Any help would be appreciated.