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?
Not quite in that way, but pretty close, as there is a regular expression match operator (~):
Note that because the first pattern match will already enter its block with only one row processed, it’s fine to have only ifs in the block.
If you really want the legibility of patterns, you could do this: