Programming Tutorials

(追記) (追記ここまで)

Calculator tutorial in Shell Script

By: Vivek G in Linux Tutorials on 2011年01月29日 [フレーム]

This shell script shows a simple calculator application.
 if test $# = 3
then
	case 2ドル in
	 +) let z=1ドル+3ドル;;
	 -) let z=1ドル-3ドル;;
	 /) let z=1ドル/3ドル;;
	 x|X) let z=1ドル*3ドル;;
	 *) echo Warning - 2ドル invalied operator, only +,-,x,/ operator allowed
	 exit;;
	esac
	echo Answer is $z
else
	echo "Usage - 0ドル value1 operator value2"
	echo " Where, value1 and value2 are numeric values"
	echo " operator can be +,-,/,x (For Multiplication)"
fi



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)

(追記) (追記ここまで)
(追記) (追記ここまで)

Related Tutorials

AltStyle によって変換されたページ (->オリジナル) /