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
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 08:34 AM
how can i put the condition in for loop for the below. mail2sant Shell Programming and Scripting 1 04-28-2008 04:49 AM
Testing For Loop condition mavsman UNIX for Dummies Questions & Answers 4 04-01-2008 11:45 AM
Checking condition inside the loop ithirak17 Shell Programming and Scripting 1 03-13-2008 08:37 AM
What condition to be put in the while loop? nehaquick UNIX for Dummies Questions & Answers 1 02-15-2008 04:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-16-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
End of loop condition required???

Hi

i have a variable with lots of tokens seperated with spaces.

e.g VAR="ABC DEF GHSD GHQS TUTSD JHDTQ QDHQ CDQKDGQ WQUTQD DQUTQD DQJGDQ QDTQD WDQUTQDU QDUGQD QDJGQD DQUTDUQ QDUIDTQ"
i want to separate all of the above tokens and call a script with each of the token e.g sh script.sh <TOKEN>



Can anybody provide the logic script ? I am cofused about the end of the loop condition.

Thanks
  #2 (permalink)  
Old 07-16-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Can you show us what you have ? Perhaps, we can guide you better when we see the script.
  #3 (permalink)  
Old 07-16-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
#!/user/bin
NAMES=`ls *.txt`
echo $NAMES

The content of this NAMES variable are TOKENS seperated by spaces.

i want to pass each token to another script called run.sh as follows:


while [<ALL tokens in $NAMES one by one>]
do
sh run.sh <TOKEN>
done

please provide the logic for seperating NAMES token and then calling run.sg with each token ????



Quote:
Originally Posted by vino View Post
Can you show us what you have ? Perhaps, we can guide you better when we see the script.
  #4 (permalink)  
Old 07-16-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by skyineyes View Post
#!/user/bin
NAMES=`ls *.txt`
echo $NAMES

The content of this NAMES variable are TOKENS seperated by spaces.

i want to pass each token to another script called run.sh as follows:


while [<ALL tokens in $NAMES one by one>]
do
sh run.sh <TOKEN>
done

please provide the logic for seperating NAMES token and then calling run.sg with each token ????
You would be better off with using a for loop
Code:
NAMES=`ls *.txt`
echo $NAMES
for file in $NAMES
do
  sh run.sh $file
done
or better yet
Code:
for file in *.txt
do
  sh run.sh $file
done
  #5 (permalink)  
Old 07-16-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
Thanks.

Its working !!!
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 05:10 AM.


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