たとえば、次のようにします。
nawk 'substr($0,42,4)=="ABCD" || substr($0,42,4)=="MNOP"' ${file}
awk
現在のコマンドには、暗黙的に処理する不要な部分がいくつかあることに注意してください。
nawk '{if (substr($0,42,4)=="ABCD") {print {$0}}}' ${file}
{print {$0}}
はデフォルトのawk
アクションであるため、条件と同様にスキップできますif {}
。すべて一緒に、あなたはそれを好きにすることができます
nawk 'substr($0,42,4)=="ABCD"' ${file}
詳細については、Idiomatic awkを確認してください。
テスト
$ 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