[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trailing newlines disappear

From: Peter & Kelly Passchier
Subject: Re: Trailing newlines disappear
Date: Fri, 9 Jun 2017 01:52:44 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

On 09/06/2560 00:42, Greg Wooledge wrote:
> It's not a bug.  This is how command substitution has worked since
> the original Bourne shell.
> The workaround is to put something inside the command substitution,
> so that the newlines aren't trailing any more, and then strip it away
> afterward:
> foo=$(cat "$file"; printf x) foo=${foo%x}

Thanks for the reply.
Seeing the hackish workaround, I would call it an ossified (or codified)

The workaround I came up with is:
mapfile <"$file"; IFS= address@hidden

This seems to be faster, but it probably has other disadvantages...


reply via email to

[Prev in Thread] Current Thread [Next in Thread]