[plug] Bash scripting. syntax error in expression

nigel nigel at dubh.id.au
Sat Mar 31 19:58:53 WST 2007


Hi list,

I have inherited a bash script and although it is now working it
displays an error on screen. The part giving me problems is;

UL="`cat /tmp/stat3.tmp |grep $1: | tr : " "| gawk '{ print $4
}'`"
CHAMT="`cat /tmp/stat3.tmp |grep -B 1 $1: |head -1| tr : " "|
gawk '{ print $4 }'`"
let CHDIFF=$(echo "$CHAMT-$UL"|bc)

The error is;
./usage.sh: line 148: let: CHDIFF=1109.97: syntax error in
expression (error token is ".97")

and in the data I am using;
CHAMT is 4649.05
UL is 3539.08

So the let statement is working as CHDIFF is given the value
1109.97. I thought that using bc takes care of the floating point
problem for bash.

Can anyone point me in the right direction?

Thanks 

Nigel






More information about the plug mailing list