title: How do awk match and ~ operators work together?
body: <p>I'm having trouble understanding this awk code:</p>
  
  <pre><code>$0 ~ ENVIRON["search"] {
    match($0, /id=[0-9]+/);
    if (RSTART) {
      print substr($0, RSTART+3, RLENGTH-3)
    }
  }
  </code></pre>
  
  <ol>
  <li><p>How do the <code>~</code> and <code>match()</code> operators interact with each other?</p></li>
  <li><p>How does the <code>match()</code> have any effect, if its output isn't printed or echo'd? What does it actually return or do? How can I use it in my own code?</p></li>
  </ol>
  
  <p>This is related to <a href="https://stackoverflow.com/questions/44164581/why-are-0-c-used-in-a-way-that-violates-usual-bash-syntax-docs-inside-an/44164896#44164896">Why are $0, ~, &amp;c. used in a way that violates usual bash syntax docs inside an argument to awk?</a>, but that question was centered around understanding the distinction between bash and awk syntaxes, whereas this one is centered around understanding the awk portions of the script.</p>