|
| From: | pepa65 |
| Subject: | Re: RFE: new syntax for command substitution to keep trailing newlines? |
| Date: | Thu, 28 Jan 2021 08:58:56 +0700 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 28/01/2021 03.29, Léa Gris wrote:
> Now if you want to preserve all the newlines you can use an ASCII EOF
> character (formerly Ctrl + Z) that is unlikely to be part of a legit
> string:
>
> a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a
When doing this there is no subshell involved so newlines are preserved:
printf -v a $'hello\n\n\n'
(I guess that wasn't your point...)
Peter
| [Prev in Thread] | Current Thread | [Next in Thread] |