使用局部变量

4年以前  |  阅读数:397 次  |  编程语言:Shell 
#!/bin/bash

# demonstrating the local keyword

function func1 {
    local temp=$[ $value +5 ]
    result=$[ $temp * 2 ]
}

temp=4
value=6

func1

echo "The result is $result"
if [ $temp -gt $value ]
then
    echo "temp is larger"
else
    echo "temp is smaller"
fi

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8