On 1/27/21 3:29 PM, 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

It doesn't matter what you use (besides a newline, of course). Just remove
a single character: a=${a%?}.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to