From owner-freebsd-questions@FreeBSD.ORG Mon Dec 1 23:50:19 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 66DC8AD6 for ; Mon, 1 Dec 2014 23:50:19 +0000 (UTC) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id 3EBC2BB8 for ; Mon, 1 Dec 2014 23:50:19 +0000 (UTC) Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.41]) by be-well.ilk.org (Postfix) with ESMTP id 45AA833C1D; Mon, 1 Dec 2014 18:50:13 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 851B239813; Mon, 1 Dec 2014 18:50:10 -0500 (EST) From: Lowell Gilbert To: Yuri Subject: Re: Shell question: how to preserve newlines when process output is assigned to variable? References: <547CF830.5000907@rawbw.com> Date: Mon, 01 Dec 2014 18:50:10 -0500 In-Reply-To: <547CF830.5000907@rawbw.com> (yuri@rawbw.com's message of "Mon, 01 Dec 2014 15:22:24 -0800") Message-ID: <4461dvvsjx.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2014 23:50:19 -0000 Yuri writes: > When script has the line like this: > VAR=$(ls) > all newlines returned by the process (ls) are removed. I don't think so. If you process the variable's contents one line at a time, you will get a separate line for each file.