The UNIX and Linux Forums  

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
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 09:49 AM
For loop xramm HP-UX 3 10-10-2007 11:20 AM
While Loop hemangjani Shell Programming and Scripting 2 11-02-2006 08:01 AM
for loop munnabhai1 Shell Programming and Scripting 3 04-06-2006 11:30 AM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 08:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-18-2006
Registered User
 

Join Date: Jan 2006
Posts: 145
Unhappy While loop help need

I have these following data about 100 row and the data is seperated by a space between each column:

5 4 0
3 7 1
9 8 7

I want to create a while loop that produce the results below:

mydata
xyz
a = 5
b = 0
c = 4
ax(1)=3
bx(1)=7
cx(1)=
dx(1)=1
ex(1)=
fx(1)=
finish
finish
ax(2)=9
bx(2)=8
cx(2)=
dx(2)=7
ex(2)=
fx(2)=
finish
finish

Please let me know if you can help!!
Reply With Quote
Forum Sponsor
  #2  
Old 09-18-2006
Registered User
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 401
Yea, I'm sure someone could help. What the heck is this used for? I can't think of a good reason to snag data like this off the top of my head.

It looks like an interesting homework problem though but you're not providing enough information. I can see why mydata is printed (data file name) and xyz must be the name of the script. If you only have three columns of data though, why are they placed in ax, bx, and dx and what's cx, ex, and fx used for? And why put "finish" at the end of the loop and why twice?

It's a puzzle.

Carl
Reply With Quote
  #3  
Old 09-18-2006
Registered User
 

Join Date: Jan 2006
Posts: 145
Unhappy

the datafile have the following information:

5 4 0
3 7 1
9 8 7
________________________________________________

This the code:

cat datafile | while read datafile
do
echo anything
echo a = $datafile
echo b = $datafile
echo c = $datafile
done

________________________________________________
The results:

anything
a = 5 4 0
b = 5 4 0
c = 5 4 0
anything
a = 3 7 1
b = 3 7 1
c = 3 7 1
anything
a = 9 8 7
b = 9 8 7
c = 9 8 7

_____________________________________________

The What I want is:

anything
a = 5
b = 4
c = 0
anything
a = 3
b = 7
c = 1
anything
a = 9
b = 8
c = 7

___________________________________________

How can I do it? CAn anyone help??? Thanks!!! sorry for the confussion!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0