would like to print everything after matching two patterns AAA and BBB.
output :
CCC
ZZZ
sample data :
AAA
BBB
CCC
ZZZ
would like to print everything after matching two patterns AAA and BBB.
output :
CCC
ZZZ
sample data :
AAA
BBB
CCC
ZZZ
Any attempt/idea/thought from your side? Did you consider the links at the bottom of this page?
try:
awk 'a[s1] && a[s2]; {a[$0]=$0}' s1="AAA" s2="BBB" infile
Anyway, one option would be
awk 'P; /AAA/ && !P {getline; if(/BBB/) P=1}' file
CCC
ZZZ
awk 'a&&b ; /AAA/ {a=1} /BBB/&&a {b=1}' file
The extra condition &&a
means that BBB must come after AAA.