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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ls while read loop - internal read picking up wrong input dkieran Shell Programming and Scripting 2 05-14-2007 03:02 PM
While read loop and rsh 104234 UNIX for Advanced & Expert Users 1 01-15-2006 11:53 AM
Please explain read in a while loop jerardfjay Shell Programming and Scripting 5 01-12-2006 10:33 AM
input inside while read loop jhansrod Shell Programming and Scripting 3 08-13-2005 10:46 AM
read inside a while loop dta4316 UNIX for Dummies Questions & Answers 3 05-21-2005 10:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-09-2008
Navatha Navatha is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 11
Need Help : while read loop

hi all,

Can you please help me with this issue ?

Code:
while [ cond1 = cond2 ] ####infinite loop 
do 
  cat file1 |while  read var1 var2
  do 
    func1 $var1 $var2
  done 
  cat file2 | while read var11 var22
  do 
    func2 $var11 $var22
  done 
done
func1 is called till all the values are read from file1
and then it picks up the func2 ....
but before all the set of values from file2 are read
and func2 is executed control is passing to func1 loop
but i want the control to go to func1 only when all the set of values from file2 are read and func2 is called ....

Warm Regards

Last edited by Franklin52; 10-09-2008 at 03:52 AM.. Reason: adding code tags
  #2 (permalink)  
Old 10-09-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Does func2 call another script?
In that case you can run the script in the background and use the wait command to wait until the background job is complete.

BTW the use of cat is redundant, to loop through a file you can do something like:

Code:
while read var1 var2
do 
  func1 $var1 $var2
done < file1
Regards
  #3 (permalink)  
Old 10-09-2008
Navatha Navatha is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 11
the func2 doesnt call any other script
it is a function defined in the same script ..
I tried placing wait command but it behaving the same way ...

I tried to print values (var11 n var22) but it is printing only 1st set of values
picked func2 and control passes to first while loop...

If I simply echoed values without passing to func2 all the set of values are printed ...

please help me out ....
Sponsored Links
Closed Thread

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 04:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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