How to pipe a here-document through a command and capture the result into a variable?

前端 未结 3 840
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 04:46

Right now this outputs the value I need on stdout. How can I capture it into a variable so I can use it in the rest of the script?

Requirements:

  • The scrip
3条回答
  •  迷失自我
    2021-02-04 05:11

    This seems to work (based on Ignacio's answer). By using a subshell the here-document is correctly piped into xsltproc while still being passed through tail after.

    VERSION=$((xsltproc - ../pom.xml | tail -1) << EOF
    
    
    
    
    EOF
    )
    

提交回复
热议问题