I have a text file with multiple log data, I would like to search for 'Keyword-1' in a line, and when it finds the line, to search within that line for another keyword such as 'engine-1'.  Then extract the section from the start of 'engine-1' until it reaches a different engine such as 'engine-2'. I would like all 'engine-1' section extracted, that includes all lines between the start and end of 'engine-1'.  The end of 'engine-1' is defined by reaching any other number such as 'engine-2' or 'engine-xx'.Note, not all lines contain the word engine, but I still want to extract the 'Data' between 'engine-1' start and 'engine-1' end.  Then moved on to the next section in the file and repeat the process by searching for keyword-1 first and finding out engine it uses, and extracted the start/end section of the new different engine.  The link between all sections would be 'keyword-1'The text file looks like this: Data engine-1 Data engine-1 Data Data Data engine-1 **keyword-1** Data engine-1 Data engine-2 Data engine-2 Data Data Data engine-2 Data engine-2 Data engine-3 Data engine-3  Data Data Data engine-3 **keyword-1** Data engine-3 Data engine-1 Data engine-1  Data Data Data engine-1Result should look like this after extraction: Data engine-1 Data engine-1 Data Data Data engine-1 **keyword-1** Data engine-1 Data engine-3 Data engine-3  Data Data Data engine-3 **keyword-1** Data engine-3
Extract multiple lines with secondary keyword search
text processing;awk