|
| From: | Léa Gris |
| Subject: | Re: RFE: new syntax for command substitution to keep trailing newlines? |
| Date: | Wed, 27 Jan 2021 21:29:24 +0100 |
| User-agent: | Telnet/1.0 [tlh] (PDP11/DEC) |
Le 27/01/2021 à 21:21, Alex fxmbsw7 Ratchev écrivait :
as well as one newline instead of x, it cuts afik _one_ ending nrwline, not all
It removes every trailing newline a=$(printf $'hello\n\n\n'); declare -p aNow 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
--
Léa Gris
| [Prev in Thread] | Current Thread | [Next in Thread] |