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

前端 未结 7 2164
臣服心动
臣服心动 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:29

    It is easy you need to echo the value you need to return and then capture it like below

    demofunc(){
        local variable="hellow"
        echo $variable    
    }
    
    val=$(demofunc)
    echo $val
    

提交回复
热议问题