First of all, *
in regex is a quantifier that means “zero or more occurrences”. Since it is a regex metacharacter, it should be escaped, \*
:
k config get-contexts | awk '/\*/{print $5}'
However, since you are looking for a fixed string rather than a pattern you can use index
:
k config get-contexts | awk 'index($0, "*") {print $5}'
If *
is found anywhere inside a “record” (the line) the fifth field will get print
ed.
solved “regular expression compile failed (missing operand)” issue in AWK when checking for an asterisk [duplicate]