title: How to merge two files consistently line by line
body: <p>I have two files (<strong>file1.txt</strong> &amp; <strong>file2.txt</strong> ). The files are only examples.</p>
  <p>How can I merge the two files, in order to create the file - <strong>merge_files.txt</strong> as example 3?</p>
  <p>I am now writing a <a href="https://en.wikipedia.org/wiki/KornShell" rel="nofollow noreferrer">KornShell</a> (<code>ksh</code>) script, so merge can be done with KornShell, <a href="https://en.wikipedia.org/wiki/AWK" rel="nofollow noreferrer">AWK</a>, <a href="https://en.wikipedia.org/wiki/Sed" rel="nofollow noreferrer">sed</a>, a <a href="https://en.wikipedia.org/wiki/Perl" rel="nofollow noreferrer">Perl</a> one-liner, etc.</p>
  <p>Background - why I need to merge the files: my target is to rename the <em>old</em> file (exist in first field) to a <em>new</em> file (exist in the second field).</p>
  <h2>Example 1</h2>
  <h3>File <em>file1.txt</em></h3>
  <pre class="lang-none prettyprint-override"><code>/etc/port1-192.9.200.1-255.555.255.0
  /etc/port2-192.9.200.1-255.555.255.0
  /etc/port3-192.9.200.1-255.555.255.0
  /etc/port4-192.9.200.1-255.555.255.0
  /etc/port5-192.9.200.1-255.555.255.0
  .
  .
  .
  .
  </code></pre>
  <h2>Example 2</h2>
  <h3>File <em>file2.txt</em></h3>
  <pre class="lang-none prettyprint-override"><code>/etc/port1-192.90.2.1-255.555.0.0
  /etc/port2-192.90.2.1-255.555.0.0
  /etc/port3-192.90.2.1-255.555.0.0
  /etc/port4-192.90.2.1-255.555.0.0
  /etc/port5-192.90.2.1-255.555.0.0
  .
  .
  .
  .
  </code></pre>
  <h2>Example 3</h2>
  <h3>File <em>merge_files.txt</em></h3>
  <pre class="lang-none prettyprint-override"><code>/etc/port1-192.9.200.1-255.555.255.0  /etc/port1-192.90.2.1-255.555.0.0
  /etc/port2-192.9.200.1-255.555.255.0  /etc/port2-192.90.2.1-255.555.0.0
  /etc/port3-192.9.200.1-255.555.255.0  /etc/port3-192.90.2.1-255.555.0.0
  /etc/port4-192.9.200.1-255.555.255.0  /etc/port4-192.90.2.1-255.555.0.0
  /etc/port5-192.9.200.1-255.555.255.0  /etc/port5-192.90.2.1-255.555.0.0
  .
  .
  .
  .
  .
  </code></pre>
  <h2>Example 4 (merge_files.txt structure)</h2>
  <pre class="lang-none prettyprint-override"><code>first field                           second field
  
  OLD file                              NEW file
  </code></pre>