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 a

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


--
Léa Gris


Reply via email to