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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sed to grep only numbers in string ajilesh Shell Programming and Scripting 5 11-07-2008 01:39 PM
How to sort a string with numbers ahjiefreak Shell Programming and Scripting 5 12-21-2007 10:52 AM
How to Compare Floating point / real numbers padarthy Shell Programming and Scripting 13 09-24-2007 08:03 PM
How do i get numbers from a string? eliraza6 Shell Programming and Scripting 13 07-18-2007 07:04 AM
problem with floating point numbers in awk kanagias Shell Programming and Scripting 7 06-24-2005 03:14 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0