次のような数行のファイルがあります。
*wordX*-Sentence1.;Sentence2.;Sentence3.;Sentence4.
これらのセンテンスの 1 つには、wordX が含まれている場合と含まれていない場合があります。私が望むのは、ファイルをトリミングして次のようにすることです。
*wordX*-Sentence1.;Sentence2.
Sentence3 が最初に wordX を含む場所です。
sed/awkでこれを行うにはどうすればよいですか?
編集:
サンプル ファイルは次のとおりです。
*WordA*-This sentence does not contain what i want.%Neither does this one.;Not here either.;Not here.;Here is WordA.;But not here.
*WordB*-WordA here.;WordB here, time to delete everything.;Including this sentece.
*WordC*-WordA, WordB. %Sample sentence one.;Sample Sentence 2.;Sample sentence 3.;Sample sentence 4.;WordC.;Discard this.
そして、ここに目的の出力があります:
*WordA*-This sentence does not contain what i want.%Neither does this one.;Not here either.;Not here.
*WordB*-WordA here.
*WordC*-WordA, WordB. %Sample sentence one.;Sample Sentence 2.;Sample sentence 3.;Sample sentence 4.