title: AWK: Using a variable as part of a regular expression
body: <p>I have a text file similar to this one containing a username, a description  and two time range values with German date format:</p>
  
  <pre><code>User###@###Description###@###1. August - 8. August 2016###@###1. September - 7. September 2016
  </code></pre>
  
  <p>Each field gets separated using the <code>###@###</code> delimiter. I would like to check if a certain field (e.g. $3) contains two identical month names. If there are two month names in this specified field, the first month name should get removed, so that the output of awk is:</p>
  
  <pre><code>User###@###Description###@###1. - 8. August 2016###@###1. - 7. September 2016
  </code></pre>
  
  <p>Then I got the idea to create a for-loop for my bash script (with awk commands), which increments <code>i</code> in order to read out the month name from a predefined variable. Here you can get a more detailed look </p>
  
  <p>script.sh:</p>
  
  <pre><code>m1=January; m2=February; m3=March; m4=April; m5=May; m6=June; m7=July; m8=August; m9=September; m10=October; m11=November; m12=December
  
  
      awk -F '###@###' '
      {for (i=1;i++;i&lt;=12){ 
      count=0;
      $3 ~ 'm'i {count++};
      if (count == 2){gsub(mi,"" ,$3)}
      }}' Info.txt &gt; Info.tmp 
  </code></pre>
  
  <p>Unfortunately it is unable to search for the varname mi (like m1, m2, m3.. etc.)</p>
  
  <p>What do I have to change in order to search a variable with a certain pattern to do some actions?</p>