awk match() multiple matches
<p>I have the following:</p>

<pre><code>echo AS:i:0  UQ:i:0  ZZ:Z:mus.sup  NM:i:0  MD:Z:50  ZZ:Z:cas.sup  CO:Z:endOfLine|awk '{match($0,/ZZ:Z[^ ]*/,m); print m[0], m[1]}' 
</code></pre>

<p>which unfortunately outputs only the first entry (out of two):  </p>

<pre><code>ZZ:Z:mus.sup 
</code></pre>

<p>It looks to me that the match() function is incapable of storing more than one match into its array. Unless I'm missing here something...? </p>

<p>If this is indeed the case, would someone kindly suggest an awk-based 'matching' alternative that will allow to obtain the two ZZ:Z entries. Note, that these are NOT located each time at the same column(!) - hence the need of using the match() function.</p>

<p>The general idea here is to obtain at the same awk command some values that appear at known column positions (e.g. col1, col2), and some values (fetched based on their unique signature "ZZ:Z") that located at unknown indexed columns.</p>

<p>In addition, the following attempt - using gensub() also fails to output/print the two ZZ:Z entries, and identify only one of the two (and the other one upon deprecation of the reciprocal..)</p>

<pre><code>echo AS:i:0  UQ:i:0  ZZ:Z:mus.sup  NM:i:0  MD:Z:50  ZZ:Z:cas.sup  CO:Z:endOfLine|awk '{val= gensub(/.*(ZZ:Z[^ ]*).*/,"\\1 \\2","g",$0);print val}'
</code></pre>

<p>the result in this case is:</p>

<pre><code>ZZ:Z:cas.sup
</code></pre>

<p>but I'd like to have as result:</p>

<pre><code>ZZ:Z:mus.sup ZZ:Z:cas.sup 
</code></pre>