help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Is there a way to not to remove tailing newline in comma


From: Tom Ryder
Subject: Re: [Help-bash] Is there a way to not to remove tailing newline in command substitution?
Date: Thu, 13 Dec 2018 16:38:32 +1300
User-agent: Mutt/1.11.1+4 (068f4921) (2018-12-03)

On Wed, Dec 12, 2018 at 09:32:33PM -0600, Peng Yu wrote:
Sometimes, it may be better to preserve the trailing newline in a command substitution. Is there a way to do so?

One method is to include a trailing character in the output, and then to strip it off again:

   $ x=$(echo $'\n'/)
   $ x=${x%/}
   $ declare -p x
   declare -- x="
   "

--
Tom Ryder <https://sanctum.geek.nz/>
The next 1<<10 years are ours.



reply via email to

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