![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| join two files | koti_rama | Shell Programming and Scripting | 5 | 08-05-2008 01:20 AM |
| Join two files | koti_rama | Shell Programming and Scripting | 4 | 06-10-2008 03:15 AM |
| how to join files | jxh461 | UNIX for Dummies Questions & Answers | 5 | 08-23-2007 04:11 AM |
| join files | mohan705 | Shell Programming and Scripting | 3 | 03-15-2007 02:51 AM |
| Join Files | choppas | Shell Programming and Scripting | 2 | 10-18-2006 07:03 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Fullouter Join of two files.
Hello All,
I have two files with following data. File1: 1,AAA 2,BBB 3,CCC 4,DDD File2: 1,XXX 2,YYY 3,ZZZ 5,EEE 6,QQQ Expected Output Should be: 1,AAA,XXX 2,BBB,YYY 3,CCC,ZZZ 4,DDD, 5, ,EEE 6, ,QQQ I tried it using awk command, but I could get only LeftOuter join. Please suggest. Thanks in advance. Amit |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks for replying Penchal.
Your command is giving me the output as below... 1,AAA,XXX 2,BBB,YYY 3,CCC,ZZZ 5,,EEE 6,,QQQ ,, I am getting all the records from file2 appended with the corrosponding values in file1. But i do not get the records present in file1 and not in file2. |
|
|||
|
Try the following script
awk -F"," ' NR == FNR { a[$1]=$2 ; next} {print $1","a[$1]","$2}' file1 file2 >> temp1 awk -F"," ' NR == FNR { a[$1]=$2 ; next} {print $1","$2","a[$1]}' file1 file2 >> temp2 cat temp1 temp2 >> final_test sort -u final_test This is working fine at my end. Thanks Penchal |