Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Dec 2014 15:22:24 -0800
From:      Yuri <yuri@rawbw.com>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Shell question: how to preserve newlines when process output is assigned to variable?
Message-ID:  <547CF830.5000907@rawbw.com>

next in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?547CF830.5000907>