Simple Calculator - kcalc

This Korn shell script implements a simple expr-like command. Arithmetic expressions are passed in as arguments, and the result is displayed. Parentheses for grouping must be escaped.

					#     kcalc - Korn Shell calculator
					# Initialize expression
					integer EXPR
					# Check usage
					if (($# == 0))
					print "$0: Must provide expression arguments."
					exit 1
					# Set/evaluate EXPR
					# Print result
					print $EXPR

Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.