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