From owner-freebsd-questions@FreeBSD.ORG Mon Dec 1 23:22:26 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F216A4C6 for ; Mon, 1 Dec 2014 23:22:26 +0000 (UTC) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id C3CAB93D for ; Mon, 1 Dec 2014 23:22:26 +0000 (UTC) Received: from eagle.yuri.org (c-73-162-232-245.hsd1.ca.comcast.net [73.162.232.245]) (authenticated bits=0) by shell1.rawbw.com (8.14.9/8.14.9) with ESMTP id sB1NMPoA000625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 1 Dec 2014 15:22:25 -0800 (PST) (envelope-from yuri@rawbw.com) X-Authentication-Warning: shell1.rawbw.com: Host c-73-162-232-245.hsd1.ca.comcast.net [73.162.232.245] claimed to be eagle.yuri.org Message-ID: <547CF830.5000907@rawbw.com> Date: Mon, 01 Dec 2014 15:22:24 -0800 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: FreeBSD Questions Subject: Shell question: how to preserve newlines when process output is assigned to variable? Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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:22:27 -0000 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