在shell中打印具有多行值的变量? [英] Print a variable with multi-line value in shell?
本文介绍了在shell中打印具有多行值的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Bash(或其他Shell)中,如何打印具有多行值的环境变量?
In Bash (or other shells) how can I print an environment variable which has a multi-line value?
text='line1
line2'
我知道一个简单的常规echo $text
不会开箱即用.
一些$ IFS调整会有所帮助吗?
I know a simple usual echo $text
won't work out of the box.
Would some $IFS tweak help?
我当前的解决方法是类似于ruby -e 'print ENV["text"]'
.
可以在纯外壳中完成吗?我想知道env
命令是否采用未解析的var名称,但似乎没有.
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.
推荐答案
与以往一样的解决方案.
Same solution as always.
echo "$text"
这篇关于在shell中打印具有多行值的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文