Capturing multiple line output into a Bash variable

后端 未结 7 2153
忘掉有多难
忘掉有多难 2020-11-22 03:17

I\'ve got a script \'myscript\' that outputs the following:

abc
def
ghi

in another script, I call:

declare RESULT=$(./myscr         


        
相关标签:
7条回答
  • 2020-11-22 04:00

    How about this, it will read each line to a variable and that can be used subsequently ! say myscript output is redirected to a file called myscript_output

    awk '{while ( (getline var < "myscript_output") >0){print var;} close ("myscript_output");}'
    
    0 讨论(0)
提交回复
热议问题