title: Merge two files using awk and write the output
body: <p>I have two files with common field. I want to merge the two files with common field and write the merged file into another file using <code>awk</code> in linux command.</p>
  
  <p><strong>file1</strong></p>
  
  <pre><code>412234$name1$value1$mark1
  413233$raja$$mark2
  414444$$$
  </code></pre>
  
  <p><strong>file2</strong></p>
  
  <pre><code>412234$sum$file2$address$street
  413233$sum2$file32$address2$street2$path
  414444$$$$
  </code></pre>
  
  <p>These sample files are seperated by <code>$</code> and output merged file also will be in <code>$</code>. Also these rows have the empty field.</p>
  
  <p>I tried the script using <code>join</code>:</p>
  
  <pre><code>   join -t "$" out2.csv out1.csv  |sort -un &gt; file3.csv
  </code></pre>
  
  <p>But there is total number mismatching happened.</p>
  
  <p>Tried with <code>awk</code>:</p>
  
  <p><strong>myawk.awk</strong></p>
  
  <pre><code>#!/usr/bin/awk -f 
  NR==FNR{a[FNR]=$0;next} {print a[FNR],$2,$3}
  </code></pre>
  
  <p>I ran it </p>
  
  <pre><code>awk -f myawk.awk out2.csv out1.csv &gt; file3.csv
  </code></pre>
  
  <p>It was also taking too much time. Not responding.</p>
  
  <p>Here <code>out2.csv</code> is master file and we have to compare with <code>out1.csv</code></p>
  
  <p>Could you please help me to write the merged files into another file?</p>