[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How not to include the trailing newline when <<< is used
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] How not to include the trailing newline when <<< is used? |
Date: |
Wed, 25 May 2016 12:30:28 -0500 |
On Tue, May 24, 2016 at 6:45 AM, Peng Yu <address@hidden> wrote:
> The following example shows that the trailing newline is include when
> <<< is used. Is there a way to not include the trailing newline
$ { [[ -f /dev/fd/0 ]] && truncate -s -1 /dev/fd/0; cat; } <<<a; echo " b"
a b
But since you're creating the herestring you may as well just measure
its length while you're at it.
$ ( x=a; head -c "${#x}" <<<"$x"; echo " b" )
a b