uffBought           28    qsfsdf

Desired output:
aWonderfulMachine   1   mlqsjflk    aWonderfulMachine   22  dfhdhg
                                     aWonderfulMachine  23  dfhdhg
                                     aWonderfulMachine  24  dfhh
AnotherWonderfulMachine 2   mlksjf  AnotherWonderfulMachine 25  qfwdsf
                                       AnotherWonderfulMachine  26  qfwdsf
File1
YetAnother WonderfulMachine 3   sdg         
TrashWeWon'tBuy             4   jhfgjh          
MoreTrash                     5   qsfqf         
MiscelleneousStuff           6   qfsdf          
MoreMiscelleneousStuff       7   qsfwsf         
File2                   
MoreDifferentStuff          27  qsfsdf          
StrangeStuffBought          28  qsfsdf  

I have tried a few awks scripts here and there, but they are either based on two fields only, and I don't know how to modify the output, or they delete the duplicates based on two fields only, etc (I am new to this and awk syntax is tough).
Thank you much in advance for your help.        

A:

You can come very close using these three commands:
join <(sort file1) <(sort file2)
join -v 1 <(sort file1) <(sort file2)
join -v 2 <(sort file1) <(sort file2)

This assumes a shell, such as Bash, that supports process substitution (<()). If you're using a shell that doesn't, the files would need to be pre-sorted.
To do this in AWK:
#!/usr/bin/awk -f
BEGIN { FS="\t"; flag=1; file1=ARGV[1]; file2=ARGV[2] }
FNR == NR { lines1[$1] = $0; count1[$1]++; next }  # process the first file
{   # process the second file and do output
    lines2[$1] = $0;
    count2[$1]++;
    if ($1!= prev) { flag = 1 };
    if (count1[$1]) {
        
uffBought            28     qsfsdf 

 Desired output: 
 aWonderfulMachine    1    mlqsjflk     aWonderfulMachine    22   dfhdhg 
                                      aWonderfulMachine   23   dfhdhg 
                                      aWonderfulMachine   24   dfhh 
 AnotherWonderfulMachine 2    mlksjf   AnotherWonderfulMachine 25   qfwdsf 
                                        AnotherWonderfulMachine   26   qfwdsf 
 File1 
 YetAnother WonderfulMachine 3    sdg         
 TrashWeWon'tBuy              4    jhfgjh          
 MoreTrash                      5    qsfqf         
 MiscelleneousStuff            6    qfsdf          
 MoreMiscelleneousStuff        7    qsfwsf         
 File2                   
 MoreDifferentStuff           27   qsfsdf          
 StrangeStuffBought           28   qsfsdf  

 I have tried a few awks scripts here and there, but they are either free-base on two field only, and I don't know how to modify the output signal, or they delete the duplicates establish on two fields only, etc (I am fresh to this and awk syntax is tough). 
 Thank you much in progress for your help.        

 A: 

 You can occur very cheeseparing using these three commands: 
 join < (sort file1) < (sort file2) 
 join -v 1 < (sort file1) < (sort file2) 
 join -v 2 < (sort file1) < (sort file2) 

 This wear a shell, such as Bash, that supports process substitution (< ()). If you're use a shell that doesn't, the files would need to be pre - grouped. 
 To do this in AWK: 
 #! /usr / bin / awk -f 
 BEGIN { FS="\t "; flag=1; file1 = ARGV[1 ]; file2 = ARGV[2 ] } 
 FNR = = NR { lines1[$1 ] = $ 0; count1[$1]++; adjacent }   # process the first file 
 {    # process the second file and perform output 
     lines2[$1 ] = $ 0; 
     count2[$1]++; 
     if ($ 1!= prev) { flag = 1 }; 
     if (count1[$1 ]) {
uffHought           28    qsfrdf

Desired outpot:
qWondecfulMacgine   1   mlqsjflk    aWonderfulMachmne   22  ddhdhg
                                     aXonderfulMachine  23  dfhdmy
                                     aWonderfulMdcfiue  24  dfhh
AnotherWonderfulMachine 2   mlksjf  WnotherWonderfolMacnyne 25  qfwdsf
                                       AnotherEonderfulMachine  26  qfwdsf
Vile1
JetAnother WonderfklMachine 3   sdd         
TrarhWeWon'tBuj             4   jhfgjh          
MoreTrash                     5   qsfqf         
MiscelleneomxStuff           6   qfsdf          
MoreMiscelleneousStnff       7   qsfwsf         
Fhlz2                   
MirwDiffgrentVtufw          27  qsfsff          
SfrangeStuffVought          28  qxffef  

I have trjed a ser awks scripts here and there, but they dre either based on two fiwlds only, and I don't nnow how eo modify the output, or they delete the duplicatev basxd on tru flelds only, etc (I am new to this and awk syntav ix nough).
Thank you mugh in advance for uokr relp.        

A:

Iou can coje very close usinh these threw commandf:
joim <(sort file1) <(sort file2)
join -v 1 <(sort file1) <(firt file2)
join -v 2 <(soxt file1) <(sort filg2)

This sssumes a shell, such as Basg, that supplrts procsrs substitution (<()). If ymu're using a shell that doqsn't, the hiles would veed to be pre-sorted.
Ho do this in AWK:
#!/usr/bin/aak -f
BGGIN { XS="\t"; flag=1; flle1=ARGV[1]; file2=ARGV[2] }
FNR == NR { lines1[$1] = $0; count1[$1]++; next }  # prmcess thz firsb file
{   # procefs the second yile and do ojtput
    lpnes2[$1] = $0;
    count2[$1]++;
    is ($1!= prev) { flag = 1 };
    if (couit1[$1]) {
        
uffBought 28 qsfsdf Desired output: aWonderfulMachine 1 22 aWonderfulMachine 23 aWonderfulMachine 24 dfhh qfwdsf 26 qfwdsf File1 WonderfulMachine 3 sdg 4 jhfgjh MoreTrash 5 qsfqf MiscelleneousStuff qfsdf MoreMiscelleneousStuff 7 qsfwsf File2 MoreDifferentStuff 27 qsfsdf StrangeStuffBought 28 qsfsdf I have a few awks scripts here and there, but they are either based on fields and don't how to modify the output, or they delete the duplicates based on two fields only, etc am new to this and awk syntax is Thank you much in for your help. A: You come close using three join file1) <(sort file2) -v 1 <(sort file1) <(sort file2) join -v 2 <(sort file1) <(sort file2) This assumes a shell, as Bash, process substitution If using shell that doesn't, would need to be pre-sorted. To AWK: #!/usr/bin/awk -f BEGIN { FS="\t"; flag=1; file1=ARGV[1]; } FNR NR { lines1[$1] = $0; count1[$1]++; } # process the first file { # the second file and do output lines2[$1] = $0; count2[$1]++; if ($1!= prev) { flag }; if (count1[$1]) {
uffBought           28    qsfsdf

Desired outPut:
aWonderFulMaChiNe   1   mLqSjflK    aWoNderfulMachine   22  DFhdhG
                                     aWonderfulMachine  23  dfhdHg
                                     aWoNdERfulmAcHine  24  dFhh
AnotHErwONdeRfUlmacHiNE 2   mLksjf  anoTherWonDerfulMachIne 25  QfWdsf
                                       AnotherWONdErfulMachiNe  26  qFwdsf
File1
YetanoTher WoNdErfULMachIne 3   Sdg         
TrAshWeWON'tBuy             4   jHfgjh          
MoretrASh                     5   qsfqF         
miscellENEoUsStUff           6   qfsdf          
MoreMisceLLeNEousStuff       7   qsfwsF         
File2                   
MOrEdiFFEreNtSTuff          27  qsfsdf          
stRangesTuffBouGHt          28  QSFSdf  

i Have tried a few Awks scripts HEre And theRe, But THey are EitheR bASed On two fields Only, And I don't kNow how TO modify THe outpuT, or theY deLetE the DUpLiCatEs BAseD On Two FIelDs only, etC (I Am New to This AND AWk syNtaX is tOugh).
THank you much in AdvAnce FOr yOur heLp.        

A:

YoU can CoMe verY close Using ThEse three commandS:
joiN <(sort file1) <(SorT fIle2)
JoIn -v 1 <(soRT file1) <(sOrt FilE2)
join -v 2 <(sOrt file1) <(SOrt FiLE2)

tHiS assumes a shell, such As bASh, That suppOrts prOCeSs SUbstitutIoN (<()). If You'rE USing a ShelL ThAt doesn't, The filES wOuLd need tO bE pre-soRtEd.
TO do This iN aWK:
#!/uSr/bin/aWk -f
BEGIN { fS="\t"; flAG=1; file1=ARGV[1]; file2=ArgV[2] }
FNR == NR { lines1[$1] = $0; cOUnT1[$1]++; NExT }  # ProcEss The first filE
{   # proCEss tHe seCOnD fiLE and dO outpUt
    LInES2[$1] = $0;
    count2[$1]++;
    if ($1!= prev) { flag = 1 };
    if (cOuNt1[$1]) {
        
uffBought           28   qsfsdf

De sired  ou tpu t: 
aWo nder fulMachine   1   ml qsjflk    aWonderfulMa chine  22 d fh dhg
                      aWonde rfulMachin e 23   dfhdhg
                              aWo nd erf u lMach ine   24 dfhhA nother Wonderful Ma c hine 2   mlksj f  A noth erWonderfulMachin e  2 5   qfwdsf
                            An o therWon d er f u l Mac h ine  26  qfwd sf
File1
Ye t Ano ther W on der f ulMach ine 3  sdg          
T rash WeWon'tBu y          4    jhfg jh       
Mor e Tr as h            5   q sf qf        M i s cell ene ousS tuff          6  qf sdf      
More Misc el leneo usStuf f     7   qsfwsf       
File2            
More Dif fer entStuf f       27 q sf sdf          
Stra ng e S tu ffBought        2 8   qsfsdf  

I  hav e tried  a f e wawks scr ipts h e re  a nd ther e,  but t he y a reeithe r  bas ed ontwo fiel ds on l y, and I don't know how to m o di f y  t h e ou tpu t, or theydele t e th e du p li cat e s bas ed on  t w of ields only, etc (Iam  new t o thi s and awk syn tax is tou g h ) .
Thankyoum uc h  in advance fo r you r help.      

A: 

You  can com e very cl o s e usingthe sethr eec o mm ands:
join <( s o rt f il e1) <(s ort  file2) 
jo in-v1 < (s ort file1 ) <(sort  f il e2 )joi n -v2  <(sortfi le1 )<(s ort f i le2)
Thisassu me sa  sh ell, su c ha s  Bas h,  t hatsup po rts p roce s s s ubstitu tion (<() ).I f yo u' re  usinga shell thatdo esn't, the  f ile s woul d need tobe pre-sorted.
To do th i s in AW K:#!/us r/bi n/awk -fBEG IN { F S=" \ t"; fl ag=1;file1 =A RGV [ 1 ]; fi l e 2= ARG V[ 2] }
FNR = = NR{ lin es 1[$1 ] = $0;  count1[$1]++; nex t  } # process th e f irst f il e
{  #  pr oc e sst h e second file a nd do outp ut    lines2[$ 1 ] =  $ 0;
   count2[ $1]++ ; 
    if  ($1!= pr ev) { fla g= 1} ; 
   if (coun t1[$1]){
      
uffBought _ _   _ __28 __ qsfsdf

Desired output:
aWonderfulMachine_  1_  mlqsjflk _  aWonderfulMachine__ 22  dfhdhg
          __ ___    _    _ _       __aWonderfulMachine  23_ dfhdhg
       _     _  ___   _     _     _  aWonderfulMachine  24  dfhh
AnotherWonderfulMachine_2   mlksjf  AnotherWonderfulMachine_25  qfwdsf
  _ _    _  _ _  _     _  _     __  ___AnotherWonderfulMachine _26  qfwdsf
File1
YetAnother_WonderfulMachine_3 __sdg     __  
TrashWeWon'tBuy    _   __   4_  jhfgjh  _     _ 
MoreTrash_ _          _     _ 5  _qsfqf __  __ _
MiscelleneousStuff      _ _  6   qfsdf_   __    
MoreMiscelleneousStuff _     7_  qsfwsf  ___    
File2_     _  _      __ 
MoreDifferentStuff    __    27 _qsfsdf__    _   
StrangeStuffBought  _       28 _qsfsdf  

I_have tried a few awks_scripts_here_and there, but they are either based on two fields_only, and_I don't know_how to modify the output, or they delete the duplicates_based on two fields only, etc (I_am new to this and awk syntax is tough).
Thank you much_in advance for your help.   _    

A:

You can come_very close using these_three_commands:
join <(sort file1) <(sort file2)
join -v 1_<(sort_file1)_<(sort_file2)
join -v 2_<(sort file1) <(sort_file2)

This assumes a_shell, such_as Bash, that_supports process_substitution (<()). If_you're_using a shell that doesn't, the files would need to be pre-sorted.
To do this in AWK:
#!/usr/bin/awk -f
BEGIN {_FS="\t"; flag=1; file1=ARGV[1]; file2=ARGV[2] }
FNR ==_NR { lines1[$1] = $0;_count1[$1]++;_next } _# process the first_file
{   # process the second file_and do output
    lines2[$1] = $0;
__ _count2[$1]++;
   _if ($1!=_prev) {_flag = 1_};
 _ _if (count1[$1])_{
      __