increment the sequence only when a specific string appears in line
I will rephrase the question
input :
AAAcjjjef
BBBifhfh
CCoiwfji
CCCifhifei
YYYjhcjh
ZZZjiddi
AAAcjjjeffdd
BBBifhdcdfh
CCoiwfdji
CCCifhdifei
YYYjhdcjh
ZZZjidddi
whenever the line starts with AAA, rest the counter
output :
1:AAAcjjjef
1:BBBifhfh
1:CCoiwfji
1:CCCifhifei
1:YYYjhcjh
1:ZZZjiddi
2:AAAcjjjeffdd
2:BBBifhdcdfh
2:CCoiwfdji
2:CCCifhdifei
2:YYYjhdcjh
2:ZZZjidddi
|