jeudi 19 janvier 2017

Select lines between two patterns including continuing instances of last pattern: sed

Yes, I have read other answers on how to select lines between two patterns or strings using sed, however this case has not been covered and I can't get it right.

I want to select the lines between two patterns, including the first pattern, and all the way up to the last instance of the second pattern. Right now I'm doing:

sed -n '/2017-01-19T11:51:39/,/2017-01-19T11:51:40/p' file.txt > extracted-file.txt

Now this will output everything from the second instance of the first pattern to the first instance of the second pattern. How can I output everything from the first instance of the first pattern to the last instance of the second pattern?

Aucun commentaire:

Enregistrer un commentaire