Use a seguinte abordagem grep :
grep -Pzo '(?s)<ticket>[^<>]*?awesome3.*?</ticket>' file.txt
A saída:
<ticket>
BASH is awesome2
BASH is awesome3
texttext
</ticket>
*?
- modificador não-ganancioso
Eu quero mostrar texto entre 3 palavras do texto em 1 arquivo:
lalala
<ticket>
BASH is awesome
BASH is awesome1
</ticket>
lalalala
<ticket>
BASH is awesome2
BASH is awesome3
texttext
</ticket>
lololo
<ticket>
awesome
BASH is awesome4
BASH is awesome5
</ticket>
lalalla
Eu tento isso:
grep -Pzo '(?s)<ticket>.*\n.*awesome3.*\n.*</ticket>' file.txt
Resultado:
<ticket>
BASH is awesome
BASH is awesome1
</ticket>
lalalala
<ticket>
BASH is awesome2
BASH is awesome3
texttext
</ticket>
lololo
<ticket>
awesome
BASH is awesome4
BASH is awesome5
</ticket>
Espera:
<ticket>
BASH is awesome2
BASH is awesome3
texttext
</ticket>
Tags grep