For example with:
nawk 'substr($0,42,4)=="ABCD" || substr($0,42,4)=="MNOP"' ${file}
Note your current command does have some unnecessary parts that awk
handles implicitly:
nawk '{if (substr($0,42,4)=="ABCD") {print {$0}}}' ${file}
{print {$0}}
is the default awk
action, so it can be skipped, as well as the if {}
condition. All together, you can let it be like
nawk 'substr($0,42,4)=="ABCD"' ${file}
For more reference you can check Idiomatic awk.
Test
$ cat a
hello this is me
hello that is me
hello those is me
$ awk 'substr($0,7,4)=="this"' a
hello this is me
$ awk 'substr($0,7,4)=="this" || substr($0,7,4)=="that"' a
hello this is me
hello that is me