2017-07-11 10 views
-2

私は複数の段落を持つファイルを持っています。私はちょうど段落を引っ張りたい。与えられた文字列を含む各ブロックを見つける方法

私はこの質問

Given line separated blocks of text, how can I return each block which contains a specific keyword?

を参照するが、溶液は私のために働いていません。ここで

は私のデータの一例

* This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. (STOP-String-023) 

* This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. (Search-String-085) 

Here is random text. Here is random text. 

* This is a block of text it goes on and on. This is a block of text it goes on and on. This is a block of text it goes on and on. (Search-String-035) 
Some text here 
Some text here 

である私は(Search-String...私はこれをどのように行うかまでの段落の先頭からテキストだけを引くしたいですか?

awk -v RS= '/Search-String[^\n]/ text.txt 

コマンドが機能しません。

+0

コード/データの前に4つの空白を付けます。 [edit-help](http://stackoverflow.com/editing-help)を見てください。 – Cyrus

+0

「検索文字列」、「085」、「035」のどの文字列ですか?また、 "ちょうど"を引っ張る? – NetMage

+1

私はあなたの質問をより理にかなって編集するために全力を尽くしましたが、私は終わりに達しました。あなたが質問を作成することをとても怠っている場合、人々はあなたを助ける傾向がありません。そして、「フレーズブックプログラミング」を使って有用なソフトウェアを書くことを期待しないでください。 – Borodin

答えて

0
awk -v RS= 'sub(/.*Search-String/,"")' text.txt 

質問が必要でない場合は、質問を編集して要件を明確にし、投稿されたサンプル入力と一緒に期待される出力を提供してください。

関連する問題