I have the following:
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]}'
which unfortunately outputs only the first entry (out of two):
ZZ:Z:mus.sup
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...?
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.
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.
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..)
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}'
the result in this case is:
ZZ:Z:cas.sup
but I'd like to have as result:
ZZ:Z:mus.sup ZZ:Z:cas.sup