With awk, I would like to insert a numbering like Record ni# in front of each line starting with Toto only when they are located in-between two specific patterns start=ABCD and stop=EFGH.Input file is: (the Blabla can be anything in reality)Blabla Toto BlablaBlabla TotoToto BlablaABCDToto BlablaToto BlablaBlablaToto BlablaEFGHToto BlablaBlabla Toto BlablaBlabla TotoABCDToto BlablaBlabla TotoToto BlablaToto BlablaBlablaEFGHToto BlablaBlabla TotoDesired output file is :Blabla Toto BlablaBlabla TotoToto BlablaABCDRecord n1#Toto BlablaRecord n2#Toto BlablaBlablaRecord n3#Toto BlablaEFGHToto BlablaBlabla Toto BlablaBlabla TotoABCDRecord n1#Toto BlablaBlabla TotoRecord n2#Toto BlablaRecord n3#Toto BlablaBlablaEFGHToto BlablaBlabla TotoI've tried the following script (which must run over bash and gawk v4.0.1), but it doesn't work :#!/bin/bashawk 'BEGIN{indice=1; FS=\n; RS=}/^ABCD$/,/^EFGH$/{if(/^Toto/){sub(/^Toto/,Record n indice\\#Toto); indice++}print}' input.txt > output.txt
With awk, how to Insert a number only for lines starting with Toto when they are between a specific couple of patterns
text processing;awk