I have a log file and I use sed to extract lines between two lines that contain the word MATCH. I use sed to extract lines and grep only for lines containing the word "MATCH". I will need the line number in the log file where the match will be found.
Date:... TST STARTS DISCARD str1 DISCARD str2 MATCH str3
I use this command to extract the rows:
sed -n "/TST STARTS/,/TST FINISHED/p" log.txt | grep "MATCHED".
My conclusion:
MATCH str3 MATCH str4
But I also need to print the line number:
line 5: MATCH str3 line 6: MATCH str4
bash grep sed
georgiana_e
source share