In Bash (or other shells) how can I print an environment variable which has a multi-line value?
text='line1
line2'
I know a simple usual echo $text
won't work out of the box.
Would some $IFS tweak help?
My current workaround is something like ruby -e 'print ENV["text"]'
.
Can this be done in pure shell? I was wondering if env
command would take an unresolved var name but it does not seem to.
text='line1<newline>line2'
(so the assignment spans two literal lines of text), ortext=$'line1\nline2'
if you are happy with restricted portability.text=$'line1\nline2'