| | |
Unixx shel script - combing information from 2 files into one useing looping structur
![]() |
•
•
Join Date: May 2007
Posts: 24
Reputation:
Solved Threads: 0
Re: Unixx shel script - combing information from 2 files into one useing looping structur
0
#11 Apr 10th, 2008
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Re: Unixx shel script - combing information from 2 files into one useing looping structur
0
#12 Apr 10th, 2008
Shell Scripting Syntax (Toggle Plain Text)
while read -r name number do while read -r NAME NUM do if NAME is equal name then echo name NUM number done < "file2" done < "file1"
Basically, this pseudo code is reading the first file and grabbing the two variables, and for each line read from the first file, it's checking every line in the second file and, if the name matches, it's print the output in the format you specified to stdout.
If you need Monday to equal Mon, etc, you can do that pretty easily with sed or even cut, if you know you only need a certain number of characters in your abbreviation (like if your standard is always 3 - Monday = Mon, Tuesday = Tue, etc)
Hope that helps. Give it a shot and see what you can do with it. Remember, the code posted is pseudo-code which means it's not entirely "correct" (won't just work if you cut-and-paste it) and is meant to demonstrate a principal and provide a means to reaching the answer rather than being the answer itself.
Best wishes,
, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Re: Unixx shel script - combing information from 2 files into one useing looping structur
0
#13 Apr 10th, 2008
BTW,
Just a friendly tip. You might want to kill the other 3 or 4 identical posts you have in this forum or an admin might delete them all.
Just trying to help out so you don't get bumped off. Hope you get your problem solved soon
, Mike
Just a friendly tip. You might want to kill the other 3 or 4 identical posts you have in this forum or an admin might delete them all.
Just trying to help out so you don't get bumped off. Hope you get your problem solved soon

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Re: Unixx shel script - combing information from 2 files into one useing looping structur
0
#14 Apr 12th, 2008
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: Required Hardware information in Linux & solaris.
- Next Thread: compare 2 files
| Thread Tools | Search this Thread |





