Shell question: how to preserve newlines when process output is assigned to variable?

Yuri yuri at rawbw.com
Mon Dec 1 23:22:27 UTC 2014


When script has the line like this:
VAR=$(ls)
all newlines returned by the process (ls) are removed.

I know shell variables can hold newlines in them when assigned inside 
the script. Just in this case, when the process output is assigned, they 
are stripped.

Any way to keep newlines?

Yuri


More information about the freebsd-questions mailing list