i cannot assign float point numbers to an array in solaris

total=0
declare -a sum[10]
limit=`iostat -En | grep -i size | awk '{print $2}' | sed -e 's/GB//g' | wc -l`
echo "Limit is equal to $limit"
ara="`iostat -En | grep -i size | awk '{print $2}' | sed -e 's/GB//g'`"
for (( i=1; i<=$limit; i++ ))
do
sum[$i]=`echo $ara | cut -d " " -f $i`
echo ${sum[$i]}
if [ $total -eq 0 ]
then
total=${sum[$i]}
else
total=`echo $total + echo ${sum[$i]} | bc`
fi
done
echo "Total Hard Disk Size is $total"

When i try to run this script it is shooting an error called

Limit is equal to 4
18.11
0.00
./totalhardisk.sh: line 11: [: 18.11: integer expression expected
syntax error on line 1, teletype
18.11
./totalhardisk.sh: line 11: [: -eq: unary operator expected
syntax error on line 1, teletype
73.40
./totalhardisk.sh: line 11: [: -eq: unary operator expected
syntax error on line 1, teletype
Total Hard Disk Size is

Please help in this regard

actually why do you need an array in this situation ?
variable 'total' itself will do right ?

sorry this is not a reply..
but pl tell me how i can post my querries on the forum?

yes mani we can even do with variable total itself. But if we want to do it with an array it is not going why ? please try solve my problem..

What shell are you using ?
The first line of your script that should tell it is missing.

i m using bash shell

$bash --version

GNU bash, version 3.00.16(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.

I don't think bash supports floating point arithmetic.

ksh (at least ksh93) does it fine.

dear jilliagre y can't i run in bash .. can u elucidate

Not sure about what to elucidate.

If bash doesn't support it, you need to explore alternative ways (ksh, bc, awk, ...)

Hi

I want to find the extact match using grep. Can anyone pls help:

my file has below content:

ABCD 123
^A\
XYZ 3564
ACVB 4324

I need to get those line with "^A\"

Thanks

cat urfilename | grep "\^A"

u will find u answer

Or simply:

grep "\^A" urfilename