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

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 09-18-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
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!!
  #2 (permalink)  
Old 09-18-2006
BOFH BOFH is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 406
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
  #3 (permalink)  
Old 09-18-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
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!
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 03:18 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