for do done loop -- my vision blurs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers for do done loop -- my vision blurs
# 1  
Old 06-10-2005
for do done loop -- my vision blurs

Someone check my code and tell me why there's no output?
I've been coding for 10 hours and I can't tell.
I've stripped every command, and broken it down to just an echo.

for FILENAME in `cat ${TMP_PATH}fxsol_ls.txt`
do
echo $FILENAME
done
# 2  
Old 06-10-2005
maybe
Code:
for FILENAME in `cat ${TMP_PATH}/fxsol_ls.txt`
do
echo $FILENAME
done

but really this would be better written as
Code:
while read FILENAME
do
echo $FILENAME
done < ${TMP_PATH}fxsol_ls.txt  ....or maybe ${TMP_PATH}/fxsol_ls.txt

also check that the value of TMP_PATH is correct by echoing it before the loop.
# 3  
Old 06-13-2005
thank You

Thank you, this worked out perfectly.
I was trying to add up the number of lines in all files of one directory and I needed this to start me off.
# 4  
Old 06-13-2005
rules: Question about loops in general

If I create a variable inside of a loop, is it available outside of the loop?

PHP Code:
for ex:
while 
read FILENAME
do
...
HAMMERS=1
...
done 
What if I created the variable, before the loop?

PHP Code:
HAMMERS=0

while read FILENAME
do
...
HAMMERS=1
...
done 
# 5  
Old 06-13-2005
answer about loops

If a variable is declared inside the loop , it wont be available outside the loop.

But if a variable is defined outside a loop , it can be used in the loop .
# 6  
Old 06-13-2005
ah great

thank you...
very useful to know.
# 7  
Old 06-13-2005
Quote:
Originally Posted by rahul123_libra
But if a variable is defined outside a loop , it can be used in the loop .
And then when you exit the loop, the variable will still hold the value that was set before the loop was entered (sometimes Smilie) see this post to save me typing out the example again...

Cheers
ZB
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

2. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

3. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

4. UNIX for Advanced & Expert Users

GigE Vision driver for VxWorks

Hello, has anybody implemented a driver for the GigE camera interface standard GigE Vision for VxWorks or knows where to aquire it? I have contacted all GigE Vision camera vendors, but most of them only have support for Windows and Linux and nobody does for VxWorks. Best regards, Anna (1 Reply)
Discussion started by: iq128
1 Replies

5. UNIX for Dummies Questions & Answers

Problem With Makefiles, how do I install gandalf vision library?

Hi, I am trying to install Gandalf, a computer vision and numerical library (http://gandalf-library.sourceforge.net/). I am using Cygwin on a Windows machine and have tried everything to get this to build, but to no avail. Gcc, make, and libtool are all included in my Cygwin install. I... (1 Reply)
Discussion started by: justinh
1 Replies
Login or Register to Ask a Question