#!/bin/ksh # Korn shell allows basic math: +, -, *, /, # and % (remainder of the division). # Korn shell only performs math on integers. # It will truncate 7.9 to 7 and 2.1 to 2. # - Jim 666-666-6666 # Define some variables: x=5; print "x is: $x" y=11; print "y is: $y" z=18; print "z is: $z" # To perform math, use double parentheses. # However, no need to use $ in front of the variable. (( Result = y + x )) print "y + x is: $Result" (( Result = z - y )) print "z - y is: $Result" (( Result = y / x )) print "y / x is (Remember returns whole number): $Result" (( Result = y % x )) print "y % x is (This is the remainder operation): $Result" # Korn shell truncates numbers to make the integers. (( Result = 1.9 + 1.9 + 1.9 )) print "In Korn shell, 1.9 + 1.9 + 1.9 is: $Result" # Adjusting position within an array/list: Position=1 Color[$Position]="Red" (( Position = Position + 1 )) Color[$Position]="Orange" print "The contents of the array \"Color\" are: ${Color[*]}" # To print just a -5 use -R. print -R "-5"