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
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
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
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
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
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
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
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
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
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
0intro 0intro intro 0intro 2a 2a 6a 2a 8a 2a ka 2a va 2a xa 2a 2c
2c 6c 2c 8c 2c kc 2c vc 2c xc 2c 2l 2l 6l 2l 8l 2l kl 2l vl 2l xl
2l 81/2 81/2 label 81/2 window 81/2 wloc 81/2 acid acid acme acme
awd acme win acme 8al alef alef alef kal alef val alef ar ar art
art art2pic art ascii ascii unicode ascii awk awk basename base-
name bc bc bind bind mount bind unmount bind bundle bundle c++
c++ c++/2c c++ c++/2l c++ c++/8c c++ c++/8l c++ c++/kc c++ c++/kl
c++ c++/vc c++ c++/vl c++ cal cal calendar calendar cat cat read
cat char char rschar char 1/2char char chgrp chgrp chmod chmod
cmp cmp comm comm con con cu con rx con telnet con xmr con xms
con cp cp mv cp cpp cpp cpu cpu date date db db dc dc dd dd dela-
tex deroff deroff deroff diff diff doctype doctype du du echo
echo ed ed emacs emacs eqn eqn factor factor primes factor file
file fmt fmt fone fone fortune fortune freq freq 4s games 5s
games ana games catclock games clock games festoon games fire-
works games fsim games games games life games mandel games plumb
games smiley games swar games grap grap graph graph grep grep gs
gs hoc hoc hp hp join join broke kill kill kill ktrans ktrans lex
lex look look lp lp lc ls ls ls aliasmail mail edmail mail mail
mail seemail mail sendmail mail smtp mail smtpd mail to mail vis-
mon mail vwhois mail lookman man man man mc mc membername mk mk
mk mkdir mkdir mothra mothra netstat netstat news news nm nm p p
page page netkey passwd passwd passwd pcc pcc pic pic tpic pic
plot plot ppp ppp pppclient ppp pppserver ppp pr pr kprof prof
prof prof proof proof ps ps psu ps pbd pwd pwd pwd cd rc eval rc
exec rc exit rc flag rc rc rc rfork rc shift rc wait rc whatis rc
~ rc rm rm B sam sam sam sam.save sam sed sed seq seq size size
sleep sleep sort sort spell spell sprog spell spin spin split
split start stop stop stop strings strings strip strip md5sum sum
sum sum syscall syscall tail tail 32vfs tapefs cpiofs tapefs
tapefs tapefs tapfs tapefs tarfs tapefs tpfs tapefs v10fs tapefs
v6fs tapefs tar tar tbl tbl tcs tcs tee tee iwhois tel tel tel
test test bibtex tex dvips tex dviselect tex latex tex mf tex tex
tex time time touch touch tr tr nroff troff troff troff tweak
tweak twig twig uniq uniq units units ki vi vi vi xi vi wc wc who
who whois who xd xd yacc yacc yesterday yesterday