What i would like to know is how to print a Range of Patterns but only if it contains a specific Pattern.
For example:
I have a file that contains:
HEADER 1
AAA
BBBBBBB
MSG:testing
CCCCCC
DDD
PAGE 1
HEADER 2
EEE
FFFFFF
GGG
HHH
PAGE 2
I want to print from any HEADER
to any PAGE
but only if it contains the pattern MSG
The result i want is to print only these section:
HEADER 1
AAA
BBBBBBB
MSG:testing
CCCCCC
DDD
PAGE 1
What i have so far is: sed -n -e '/HEADER /,/PAGE /p' inputfile.txt > outputfile.txt
I'm open to any suggestions including the usage of Awk or Grep.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire