The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-29-2009
tintin72 tintin72 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 23
Using Floating Numbers in String

Dear Unix Gurus,

I have a list of files that I want to loop over....for example:
Code:
 
sl40_z11.70.txt
sl41_z11.40.txt
sl42_z11.10.txt
sl43_z10.80.txt
using the script

Code:
 
#!/bin/sh
#
echo -n "....enter first Z-coordinate position....."; read zpos
q="scale=3; $zpos"
p=0.3
#
loopNumber=$[($lastslice - $firstslice)+1]
echo "loopNumber is $loopNumber"
echo firstslice no. is $firstslice
 
for ((i=$firstslice; i<=$loopNumber; i++)); do 
n=$[i]
for ((k=0; k<=$loopNumber; k++)); do 
r=$[k] ; f=$r*$p ; zposition=$q-$f 
 
echo "sl$[n]_z$[zposition].txt"
 
done
done
where firstslice is 40 and lastslice is 43 and 0.3 is the difference in z-cordinate btw the files.

My problem is that the script works fine with the exception that bash doesn't recognize $zposition. It apparently can't handle iteration with floating numbers? Can someone help?

Cheers