Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような一連の行を含むファイルがあります。
dbxxx dbxxxx dbxx tdxx tdxxx sbxx sbxxxxx dbxx_migrated tdxxx_old
ここで、x = 1 桁です。
db、td、および sb で始まる行を確実に表示し、_migrated および _old を含むすべての行を除外する出力を作成する必要があります。
grepを使用してこれを行うことは可能ですか?
awk正規表現と論理演算子を次のように組み合わせることができます。
awk
$ awk '/^(db)|(td)|(sb)/ && !/_(old)|(migrated)/' file dbxxx dbxxxx dbxx tdxx tdxxx sbxx sbxxxxx