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
awk, join or sed jkl_jkl Shell Programming and Scripting 1 04-15-2008 05:55 AM
Join jazz8146 UNIX for Dummies Questions & Answers 5 01-29-2008 11:42 AM
join (pls help on join command) summer_cherry Shell Programming and Scripting 1 12-31-2007 05:19 AM
Join Files choppas Shell Programming and Scripting 2 10-18-2006 10:03 AM

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

Join Date: Feb 2007
Posts: 2
A join problem?

Hi everybody,

I am hoping somebody here will be either be able to solve my troubles or at least give me a push in the right direction .

I am developing a shell script to read in 4 different files worth of data that each contain a list of:

username firstname secondname group score

I have got my script sorting the files into a final file with the format

username firstname secondname group score score score score

I have a solution to do this working fine using join until I get one situation. The names listed do not appear in all files and I need to put 0 in for the score when the name is missing. But join is making firstname, secondname and group become 0's too if the person is missing in any file but the last.

The current code im using is:

Code:
join -a 1 -a 2 -o 0 2.2 2.3 2.4 1.5 2.5 -e "0" ass1.$$ ass2.$$ |
        join -a 1 -a 2 -o 0 2.2 2.3 2.4 2.5 1.5 1.6 2.5 -e "0" - ass3.$$ |
                join -a 1 -a 2 -o 0 2.2 2.3 2.4 1.5 1.6 1.7 2.5 -e "0" - ass4.$$ > sorted.$$
How can i solve this? I have tried searching Google and have spent time looking through many examples. Just with no similar solution to what i am looking for.

Thank you for your help in advance.

Jamie
  #2 (permalink)  
Old 02-06-2007
jamjamjammie jamjamjammie is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 2
Does anybody have a solution?
  #3 (permalink)  
Old 02-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,420
A possible way :
Modify your input files :
Code:
username firstname secondname group,score
and try something like that :
Code:
join -t, -a 1 -a 2 -o 0 1.2 2.2  -e "0" ass1.$$ ass2.$$ |
join -t, -a 1 -a 2 -o 0 1.2 1.3 2.2  -e "0" -   ass3.$$ |
join -t, -a 1 -a 2 -o 0 1.2 1.3 1.4 2.2  -e "0" - ass4.$$ > sorted.$$

Jean-Pierre.
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 09:41 PM.


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