Sponsored Content
Operating Systems Solaris i cannot assign float point numbers to an array in solaris Post 302170197 by naree on Monday 25th of February 2008 01:32:56 AM
Old 02-25-2008
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
 

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

how to assign same mount point for file systems mounted on physical disks

We have 6 hard disks attached to the hardware. Of this 2 hard disks are of 9 GB each. Now I want combine both the same in such a way that i see a combined entry in the output of df -k . The steps I follow are 1. Create partition on hard disks (Using format partition) 2. Run newfs -v for... (6 Replies)
Discussion started by: Hitesh Shah
6 Replies

2. Shell Programming and Scripting

adding float numbers

how to add 2 float values to each other? i tried this and it doesnt work: #!bin/bash numone=1.234 numtwo=0.124 total=`expr $numone + $numtwo` echo $total thanks (5 Replies)
Discussion started by: strike
5 Replies

3. Solaris

can array store float point numbers

Hi all, I have doubt can array in a shell script can store floating point numbers. i have tired. but i unable to work it out. Please help me regarding this Thank U Naree (1 Reply)
Discussion started by: naree
1 Replies

4. Programming

comparison between float numbers

Hi, i have a simple control like this: if(sum>1.0)... If i try to print sum i get 1.000000 but the check returns true. I think it depends on float precision. How can i modify the check? thanks (1 Reply)
Discussion started by: littleboyblu
1 Replies

5. Shell Programming and Scripting

Random float numbers in BASH

Hi people :) I'm learning shell scripting using bash and I want to generate 4 floating point number with 5 decimal places and write them to a file and a variable. I've done all this except the $RAMDOM enviroment variable does not generate a float number but a integrer. I hope you could... (3 Replies)
Discussion started by: pharaoh
3 Replies

6. Shell Programming and Scripting

Can't assign float value into another variable

hello I have write one script which calculate result of student and takes input from file named "student.txt". This file has filed name rollno, name, mark1,mark2 and mark3. My problem is that i want percentage with 2 floating point. I have write whole shell script but it can't work. Code is... (2 Replies)
Discussion started by: csharpque
2 Replies

7. Shell Programming and Scripting

How to Assign an shell array to awk array?

Hello All, Can you please help me with the below. #!/bin/bash ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1" ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies

8. Shell Programming and Scripting

Float array sum

Hi everyone, I'm having some trouble with float array. When i try to get the array sum with float numbers i get this error line 39: soma + 2.34 | bc: syntax error: invalid arithmetic operator (error token is ".34 | bc") 26 Somar() { 27 echo "Quantos numeros deseja somar?" 28 read... (4 Replies)
Discussion started by: berveglieri
4 Replies

9. Shell Programming and Scripting

Help about using variables of float numbers in sed

Hi, I need to run a Fortran program which reads a input file with a fixed name many times, each time I need to change a number (real) in that input file, this is how I currently do it and I know it is not elegent at all: cp inputfile.dat backup.dat sed -i 's/28.0/0.01/g' inputfile.dat ./myCode... (3 Replies)
Discussion started by: dypang
3 Replies
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy