title: comparing two files by lines and removing duplicates from first file
body: <p><strong>Problem:</strong></p>
  
  <ol>
  <li>Need to compare two files,</li>
  <li>removing the duplicate from the first file</li>
  <li>then appending the lines of file1 to file2  </li>
  </ol>
  
  <p><strong>Illustration by example</strong> </p>
  
  <p>Suppose, The two files are test1 and test2.</p>
  
  <pre><code>$ cat test2
  www.xyz.com/abc-2
  www.xyz.com/abc-3
  www.xyz.com/abc-4
  www.xyz.com/abc-5
  www.xyz.com/abc-6
  </code></pre>
  
  <p>And test1 is</p>
  
  <pre><code>$ cat test1
  www.xyz.com/abc-1
  www.xyz.com/abc-2
  www.xyz.com/abc-3
  www.xyz.com/abc-4
  www.xyz.com/abc-5
  </code></pre>
  
  <p><strong>Comparing test1 to test2</strong> and removing duplicates from test 1</p>
  
  <p>Result Required:</p>
  
  <pre><code>$ cat test1
  www.xyz.com/abc-1
  </code></pre>
  
  <p>and then adding this test1 data in to test2</p>
  
  <pre><code>$ cat test2
  www.xyz.com/abc-2
  www.xyz.com/abc-3
  www.xyz.com/abc-4
  www.xyz.com/abc-5
  www.xyz.com/abc-6
  www.xyz.com/abc-1
  </code></pre>
  
  <p><strong>Solutions Tried:</strong></p>
  
  <pre><code>join -v1 -v2 &lt;(sort test1) &lt;(sort test2)
  </code></pre>
  
  <p>which resulted into this (that was wrong output)</p>
  
  <pre><code>$ join -v1 -v2 &lt;(sort test1) &lt;(sort test2)
  www.xyz.com/abc-1
  www.xyz.com/abc-6
  </code></pre>
  
  <p>Another solution i tried was :</p>
  
  <pre><code>fgrep -vf test1 test2
  </code></pre>
  
  <p>which resulted nothing.</p>