duanlou2917 2013-03-12 17:16
浏览 103
已采纳

将变量替换为多行shell变量

I'm building an email message by reading some rows from a database into a multiple line shell variable called EMAIL_DESC:

EMAIL_DESC=`run "select text from  ETL.MAIL_TEXT where ID=1 order by id, text_order"`

Unfortunately I have variables and commands (date) inside $EMAIL_DESC but I can't substitute them in any way.

echo "$EMAIL_DESC"
Please be aware that all user tables and views on the $SERVER_DESC
Ended = `date`.

Any idea?

  • 写回答

2条回答 默认 最新

  • duanmei1350 2013-03-12 18:09
    关注

    Question is not very clear. But whatever I can understand I think you're looking for the evil eval here. Consider this:

    x='Foo
    Bar
    $HOME
    Baz
    $SHELL'
    
    echo $x
    eval echo $x
    

    OUTPUT:

    Foo Bar $HOME Baz $SHELL
    Foo Bar /home/alex Baz /bin/bash
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面