私のファイルは.txtです:
this is for testing
so test
againa and again
zzz and ssss
this is for testing
so test
againa and again
ここで、zzz と test の間で test を抽出しようとしています。
cat a.txt | sed -n '/zzz/,/test/p'
出力:
zzz and ssss
this is for testing
so test
問題は次のとおりです。
cat a.txt | sed -n '/zzz/,/jjj/p'
ファイルに存在しない単語 (jjj) を保持しようとすると、zzz
ファイルの末尾からデータが返されます。何も返さないことが理想的です。