Capturing multiple line output into a Bash variable

后端 未结 7 2148
忘掉有多难
忘掉有多难 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");}'
    

提交回复
热议问题