Bash read output?

前端 未结 1 1754
余生分开走
余生分开走 2020-12-29 09:56

I\'m running this at a terminal on Ubuntu 11.4.

Say I execute a bash script and the output is:

Test1: Some text...
Test2: Some text...
Test3: Some te         


        
相关标签:
1条回答
  • 2020-12-29 10:15

    So you want

    output=$(command)
    while read -r line; do
        process "$line"
    done <<< "$output"
    

    See "Here strings" in the Bash manual.

    or process substitution

    while read -r line; do
        process "$line"
    done < <(command)
    
    0 讨论(0)
提交回复
热议问题