文章出處

文件名為: 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


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()