title: Bash: Replace strings in file with an array
body: <p>I want to replace strings in a file using a bash array.</p>
  
  <p>e.g. the file example.txt: </p>
  
  <pre><code>A: Netherlands
  B: Germany
  C: United States
  A: Netherlands
  [Edit #2: In the file are also different strings without the format X:Y]
  C, N: United States
  </code></pre>
  
  <p>Now I want to have a bash script to replace the letters (Edit: before the colons) so it becomes</p>
  
  <pre><code>A =&gt; Amsterdam
  B =&gt; Berlin
  C =&gt; Chicago
  N =&gt; New York
  </code></pre>
  
  <p>So finally I want to have</p>
  
  <pre><code>Amsterdam: Netherlands
  Berlin: Germany
  Chicago: United States
  Amsterdam: Netherlands
  [Edit #2: In the file are also different strings without the format X:Y]
  Chicago, New York: United States
  </code></pre>
  
  <p>And this using a bash script but it won't matter if we include other scripting languages like perl.</p>
  
  <p>Thank you!</p>