title: Merge tab-delimited files based on first 8 columns
body: <p>I have a tab-delimited file (let's call it file1) that looks like this:</p>
  
  <pre><code>NC_027300.1 Gnomon  exon    5501    5691    .   -   .   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  exon    16966   17019   .   -   .   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  exon    23978   24241   .   -   .   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  exon    43486   43714   .   -   .   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  exon    61647   62139   .   -   .   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  CDS 5501    5691    .   -   2   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  CDS 16966   17019   .   -   2   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  CDS 23978   24241   .   -   2   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  CDS 43486   43633   .   -   0   gene_id "1"; transcript_id "1.1";
  NC_027300.1 Gnomon  exon    160437  160638  .   -   .   gene_id "2"; transcript_id "2.1";
  NC_027300.1 Gnomon  exon    160913  161019  .   -   .   gene_id "2"; transcript_id "2.1";
  </code></pre>
  
  <p>And a larger tab-delim file (file2) that looks like this:</p>
  
  <pre><code>NC_027300.1 Gnomon  gene    5501    62139   .   -   .   ID=gene0;Dbxref=GeneID:106560212;Name=LOC106560212;gbkey=Gene;gene=LOC106560212;gene_biotype=protein_coding
  NC_027300.1 Gnomon  mRNA    5501    62139   .   -   .   ID=rna0;Parent=gene0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;Name=XM_014160784.1;gbkey=mRNA;gene=LOC106560212;model_evidence=Supporting evidence includes similarity to: 99%25 coverage of the annotated genomic feature by RNAseq alignments%2C including 8 samples with support for all annotated introns;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  exon    61647   62139   .   -   .   ID=id1;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  exon    43486   43714   .   -   .   ID=id2;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  exon    23978   24241   .   -   .   ID=id3;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  exon    16966   17019   .   -   .   ID=id4;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  exon    5501    5691    .   -   .   ID=id5;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  NC_027300.1 Gnomon  CDS 43486   43633   .   -   0   ID=cds0;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XP_014016259.1;Name=XP_014016259.1;gbkey=CDS;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;protein_id=XP_014016259.1
  NC_027300.1 Gnomon  CDS 23978   24241   .   -   2   ID=cds0;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XP_014016259.1;Name=XP_014016259.1;gbkey=CDS;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;protein_id=XP_014016259.1
  NC_027300.1 Gnomon  CDS 16966   17019   .   -   2   ID=cds0;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XP_014016259.1;Name=XP_014016259.1;gbkey=CDS;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;protein_id=XP_014016259.1
  </code></pre>
  
  <p>I would like to create a new file that only contains lines from file1 that are also present in file2, based on the first 8 columns, that has all 9 columns from file1 and column 9 of file2 as column 10. Like this:</p>
  
  <pre><code>NC_027300.1 Gnomon  exon    5501    5691    .   -   .   gene_id "1"; transcript_id "1.1"; ID=id5;Parent=rna0;Dbxref=GeneID:106560212,Genbank:XM_014160784.1;gbkey=mRNA;gene=LOC106560212;product=fibroblast growth factor receptor 3-like;transcript_id=XM_014160784.1
  </code></pre>
  
  <p>I have been trying to follow <a href="https://stackoverflow.com/questions/12994298/properly-join-two-files-based-on-2-columns-in-common">this example</a> and this is (with my very limited knowledge) what I came up with:</p>
  
  <pre><code>awk 'NR==FNR{a[$1,$2,$3,$4,$5,$6,$7,$8]=$10;next} ($1,$2,$3,$4,$5,$6,$7,$8) in a{print $0, a[$$1,$2,$3,$4,$5,$6,$7,$8]}' file1 file2 &gt; newfile
  </code></pre>
  
  <p>Could someone please tell me if I'm anywhere near and help if it's wrong? My files are 1M+ lines and this is running at the moment but I fear it could be a while before I can even see if it's working!! Thanks in advance</p>