Artificial intelligent assistant

awk extended pattern matching (embedding pattern matching in actions for already matched strings) I want handle strings of the form: PREFIX_TYPE_N,DATA So, does the *awk (gawk, mawk, nawk) support including pattern matching in the action for already matched string? Something like this (of course, doesn't work for me): *awk 'BEGIN { FS="," } /PREFIX/ { /TYPE_1/ {printf "[TYPE1] [DATA: $2]"} // <-- included pattern /TYPE_2/ {printf "[TYPE2] [DATA: $2]"} // <-- another included pattern ... // <-- some more included patterns }' "filename" Or do I still need if/else or switch/case?

This should work, but I'm not an expert of awk so there might be better answers if you wait:


*awk 'BEGIN { FS="," }
/PREFIX/ {
if ($0 ~ /TYPE_1/) {printf "[TYPE1] [DATA: $2]"} // <-- included pattern
if ($0 ~ /TYPE_2/) {printf "[TYPE2] [DATA: $2]"} // <-- another included pattern
... // <-- some more included patterns
}' "filename"

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 10a449d2a45355536808c6e739def1d3