Saturday, May 23, 2020

Basic Mathematical Operations in Kornshell

#!/bin/ksh
x=5;print "x is : $x"
y=10;print "y is : $y"
z=15;print "z is : $z"
((Result=x+y))
print "The sum of $x and $y is $Result"
((Subtraction=z-y))
print "The subtraction of $y from $z is $Subtraction"
((Division=x/y))
print "The division of $x by $y is $Division"
Position=1
color[$Position]="Red"
((Position=Position+1))
color[$Position]="Orange"
print "the contents of the \"Color\" array are ${color[*]}"
#to print something preceding with a minus symbol
print -R  "-5" 
#to see if my korn shell supoorts decimal
((result=1.9+1.9))
print "In my version of kornshell 1.9 + 1.9 is $result"

No comments:

Post a Comment