#!/bin/bash #This is a test of the addition of the program! function AddFun { read -p "Enter a number:" num1 read -p "Enter another number:" num2 echo $[ $num1 + $num2 ] } result=`AddFun` echo "The Result is :$result"
上面這段代碼主要實現的功能是建立一個函數,通過控制台輸入2個數字后,求這兩個數字之后並輸出結果。這個程序並不是很難,但是新手剛寫,真的未必寫得出來的。放在這里,只是一個點滴積累,在忘記語法的時候可以有個查看的依據----2016年11月的第一天