The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: A join problem?
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #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