title: BASH echo with sed
body: <p>I have:</p>
  
  <p>Location.txt (content)</p>
  
  <pre><code>some_line1
  some_line2
  some_line3
  </code></pre>
  
  <p>region.txt (content)</p>
  
  <pre><code>region1
  region2
  region3
  </code></pre>
  
  <p>uri.txt (content)</p>
  
  <pre><code>/some_text/some_text1/***/
  /some_text/***/some_text2/
  /***/some_text/some_text3/
  </code></pre>
  
  <p>I need to create files </p>
  
  <pre><code>region1
  region2
  region3
  </code></pre>
  
  <p>and each of them have to fill with the following (name of the region instead of stars)</p>
  
  <p>Example of file region1</p>
  
  <pre><code>/some_text/some_text1/region1/
  some_line1
  some_line2
  some_line3
  
  /some_text/region1/some_text2
  some_line1
  some_line2
  some_line3
  
  /region1/some_text/some_text3
  some_line1
  some_line2
  some_line3
  </code></pre>
  
  <p>Example of file region2 (name of the region instead of stars)</p>
  
  <pre><code>/some_text/some_text1/region2/
  some_line1
  some_line2
  some_line3
  
  /some_text/region2/some_text2
  some_line1
  some_line2
  some_line3
  
  /region2/some_text/some_text3
  some_line1
  some_line2
  some_line3
  </code></pre>
  
  <p>Now I have</p>
  
  <pre><code>#!/bin/bash
  
  while read region
      do
          while read uri
          do
              echo $uri &gt;&gt; "/home/user/regions/$region"
          done &lt; uri.txt
      done &lt; region.txt
  </code></pre>
  
  <p>This script creates files with names of lines from <code>region.txt</code> and fill it with lines from <code>uri.txt</code>.</p>
  
  <p>But I have to make a lot of files. Each file should be filled with many locations but one line in each location should be changed to line from <code>uri.txt</code>.</p>
  
  <p>Looks like I have to use</p>
  
  <pre><code>cat $file|sed 's/^was/now/'
  </code></pre>
  
  <p>but I dont know how to use it.</p>
  
  <p>Any help please.</p>