Awk-if problem

Hi

This's my problem ( AIX )

switchshow | awk ' { if ( $1==0 ) print $0; }'

It works
But these below doesn't

switchshow | awk ' { if ( $1==0 1 2 3 4 7 9 12 15 ) print $0; }'
switchshow | awk ' { if ( $1==[0-4] 7 9 12 15 ) print $0; }'

Somebody help, please :(:(:frowning:

switchshow | awk '$1 ~ /^([0-479]|1[25])$/'
1 Like

If you are more comfortable using distinct list of allowed values you could also try:

switchshow |  awk '{ if ($1 ~ "^(0|1|2|3|4|7|9|12|15)$") print }'

Note ^ matches start of string and $ matches end of string.

1 Like

Wow, both commands worked. Thanks guys. Can't find it anywhere