Store value to variable in Shell script

This question already has an answer here:

  • How to set a variable to the output of a command in Bash? 13 answers

  • You have to use the right quotation, like this:

    total_rows=`echo "$emails" | ./jq '.total_rows'`
    

    The `` will execute the command and give total_rows the value of it, so whatever would be the output of

    echo "$emails" | ./jq '.total_rows'
    

    will so be stored in total_rows .

    链接地址: http://www.djcxy.com/p/57200.html

    上一篇: 如何将bash命令的输出存储在变量中?

    下一篇: 将值存储到Shell脚本中的变量