title: using variables in search pattern in awk script
body: <pre><code>#!/usr/local/bin/gawk -f  `
  
  {  
  awkvar2="/id=22/";  
  awkvar3="/end/";  
  
  
  if ($0 ~ awkvar2) {  
      triggered=1;  
    }  
    if (triggered) {  
       print;  
       if ($0 ~ awkvar3) {  
          triggered=0;  
          print "\n-----------------------------------------------\n"  
       }  
    }  
  }  
  </code></pre>
  
  <p>this awk script is not working for me
  i am trying to search from one line to another i.e <code>id=22</code> till <code>end</code>
  (the reason i am not using <code>/&lt;string&gt;/,/&lt;string&gt;/</code> is because i want a big line after each block of search)
  and i want this using variables only.<br>
  i could directly use the patterns <code>if ($0 ~ /end/) {</code>
  but i dont want to do that, i want to use the variables inside the search pattern
  (reason is i will be getting the values in the variables dynamically thorough the shell)</p>
  
  <p>please advise me how to use variables inside the search pattern for awk</p>
  
  <p>thanks...</p>