title: AWK merging two files with more conditions
body: <p>I need help with merging two files.</p>
  
  <p>1st file:</p>
  
  <pre><code>header1
  raw1 spec1/W a b c d
  raw2 spec2/W a c d d
  raw3 spec3/W a d b b 
  </code></pre>
  
  <p>2nd file:</p>
  
  <pre><code>headerXX
  headerY
  headerZ
  z a d a r z j z u o p 45600 raw1 a d spec1 b d a ....
  d a r a f g h z u i d 6054  raw2 a f   a   s a spec2 ...
  k o k o j o p s t d v 5000  raw3 d f a f g h  ...
  </code></pre>
  
  <p>Output file:</p>
  
  <pre><code>header1 
  raw1 spec1/W a b c d 45600
  raw2 spec2/W a c d d 6054
  raw3 spec3/W a d b b (there won't be number because no spec.)
  </code></pre>
  
  <p>I would like to merge $1st from first file with $13th from second file while splited $2nd (without "/W") in first file with $16th or $19th in second file. If match print 1st file and $12 from second file, if missmatch print only $1 file.</p>
  
  <p>If it is could help you:</p>
  
  <p>for first match :</p>
  
  <pre><code>awk -F'\t' -v OFS="\t" 'FNR==NR{a[$1]++; next}; $13 in a {print $0,??}' 
  </code></pre>
  
  <p>and for second match I think something like:</p>
  
  <pre><code>awk -F'\t' -v OFS="\t" '{split($2,a,"/") print $1,a[1],$2,$3,$4,$5,$6}' | awk 'FNR==NR{a[$2]++; next}; $16 || $19 in a {print $0,??}' 
  </code></pre>
  
  <p>Tahnk you so much.</p>