2番目のフィールドに特定のパターンを含むCSVの行を削除する

2番目のフィールドに特定のパターンを含むCSVの行を削除する

2番目のフィールドに単語を含む.csvファイルから行を削除する方法はcontent

例:

ams-hbase-log4j,content:\n#LicensedtotheApacheSoftwareFoundation(ASF)underone\n#ormorecontributorlicenseagreements
ams-log4j,content:\n#\n#LicensedtotheApacheSoftwareFoundation(ASF)underone\n#ormorecontributorlicenseagreements.
ams-site,timeline.metrics.cache.size:150,

期待される出力

ams-site,timeline.metrics.cache.size:150,

ベストアンサー1

sed2番目のフィールドに含まれる行を使用して削除するには、content次の手順を実行します。

sed '/^[^,]*,[^,]*content/d' infile

または、2番目のフィールドの行を削除してください。そしてcontent

sed '/^[^,]*,content/d' infile

おすすめ記事