How to preserve line breaks when storing command output to a variable?

前端 未结 2 1634
無奈伤痛
無奈伤痛 2020-11-29 19:58

I’m using bash shell on Linux. I have this simple script …

#!/bin/bash

TEMP=`sed -n \'/\'\"Starting deployment of\"\'/,/\'\"Failed to start context\"\'/p\'         


        
2条回答
  •  死守一世寂寞
    2020-11-29 20:14

    I have ran into the same problem, a quote will help

    ubuntu@host:~/apps$ apps="abc
    > def"
    ubuntu@host:~/apps$ echo $apps
    abc def
    ubuntu@host:~/apps$ echo "$apps"
    abc
    def
    

提交回复
热议问题