文章出處
文章列表
文件名為: test5.sh
#!/bin/bash # using the return command in a function function db1 { read -p "Enter a value:" value echo "docubling the value" return $[ $value * 2 ] } db1 echo "The new value is $?"
運行 sh test5.sh
輸出為 Enter a value: 鍵盤輸入23后輸出
docubling the value The new value is 46
注:輸入的數字大于125則會返回錯誤,因為輸出'$?'的值最大不超過256
文章列表
全站熱搜