1753522 Members
11041 Online
108795 Solutions
New Discussion юеВ

Re: expr command help

 
SOLVED
Go to solution
piyush mathiya
Trusted Contributor

Re: expr command help

Thanks,
James R. Ferguson
Acclaimed Contributor

Re: expr command help

Hi:

Most shells only support integer arithmetic as you have found. While I would probably also use 'awk' (or Perl), the Korn93 shell supports floating point arithmetic.

In HP-UX the Korn shell in '/usr/bin/ksh' is the Korn88 variant and this lacks the support you seek.

However, the Korn93 shell lives in '/usr/dt/bin/dtksh'. For example:

# cat ./float
#/usr/dt/bin/dtksh
typeset -F R1
typeset -F3 R2
typeset -E R3
let R1=1/8
echo $R1
let R2=1/8
echo $R2
let R3=1/8
echo $R3

# ./float
.1250000000
.125
0.125

A google search for 'Korn shell' will yield more information.

Regards!

...JRF...