In bash, how to store a return value in a variable?

前端 未结 7 2160
臣服心动
臣服心动 2020-11-29 09:06

I know some very basic commands in Linux and am trying to write some scripts. I have written a function which evaluates the sum of last 2-digits in a 5-digit number. The fun

7条回答
  •  情深已故
    2020-11-29 09:40

    Use the special bash variable "$?" like so:

    function_output=$(my_function)
    function_return_value=$?
    

提交回复
热议问题