[plug] Bash scripting. syntax error in expression

Mark O'Shea mark at musicalstoat.co.uk
Sat Mar 31 20:37:25 WST 2007


On Sat, 2007-03-31 at 19:58 +0800, nigel wrote:
> 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?
Yes, take out the let, you don't need to evaluate it twice, the second
time (by bash) is causing the error.

-- 
Mark O'Shea 




More information about the plug mailing list