title: How to use AWK to filter matrix patterns for user CNs?
body: <p>this one was tricky: I have a text file with several user DNs and bellow each one a matrix with the LogonHours pattern (extracted from Active Directory using PowerShell). Looks like this:</p>
  
  <pre><code>CN=John Doe,OU=Users,OU=Almox,DC=acme,DC=inc
      Day
      of   --------- Daily  Hours --------
      Week M-3 3-6 6-9 9-N N-3 3-6 6-9 9-M
      Dom  000 000 000 000 000 000 000 000
      Seg  000 000 011 111 111 111 100 000
      Ter  000 000 011 111 111 111 100 000
      Qua  000 000 011 111 111 111 100 000
      Qui  000 000 011 111 111 111 100 000
      Sex  000 000 011 111 111 111 100 000
      Sab  000 000 000 000 000 000 000 000
  CN=Jack Dumb,OU=Users,OU=Managers,DC=acme,DC=inc
      All Hours
  CN=Barry Foo,OU=Disabled Users,DC=acme,DC=inc
      Day
      of   --------- Daily  Hours --------
      Week M-3 3-6 6-9 9-N N-3 3-6 6-9 9-M
      Dom  000 000 000 000 000 011 111 111
      Seg  111 111 111 111 111 111 111 111
      Ter  111 111 111 111 111 111 111 111
      Qua  111 111 111 111 111 111 111 111
      Qui  111 111 111 111 111 111 111 111
      Sex  111 111 111 111 111 111 111 111
      Sab  111 111 111 111 110 000 000 000
  </code></pre>
  
  <p>How can I extract usernames with an specific LogonHours pattern with AWK?</p>
  
  <p>I was able to count the number of specific patterns using AWK using a "pattern file" as a RS as follows:</p>
  
  <pre><code>awk -v RS="$(&lt;patternfile.txt)" '{print RT}' logonhoursCNlist.txt | grep "Week M-3" | wc -l
  </code></pre>
  
  <p>Expected result using a patternfile with the following content...</p>
  
  <pre><code>Day
  of   --------- Daily  Hours --------
  Week M-3 3-6 6-9 9-N N-3 3-6 6-9 9-M
  Dom  000 000 000 000 000 000 000 000
  Seg  000 000 011 111 111 111 100 000
  Ter  000 000 011 111 111 111 100 000
  Qua  000 000 011 111 111 111 100 000
  Qui  000 000 011 111 111 111 100 000
  Sex  000 000 011 111 111 111 100 000
  Sab  000 000 000 000 000 000 000 000
  </code></pre>
  
  <p>... is just the usernames on CNs, like this:</p>
  
  <pre><code>John Doe
  </code></pre>
  
  <p>Any help I'll appreciate!</p>