I know that multiline regexp has been discussed dozens of times but I just can't get it to work with my pattern.
I'll try to explain. I have some text files in a directory. Example of text in a file:
LINE OF TEXT 2
LINE OF TEXT 1
LINE OF TEXT 3
LINE OF TEXT 1
LINE OF TEXT 2
LINE OF TEXT 3
LINE OF TEXT 1
LINE OF TEXT 3
LINE OF TEXT 3
LINE OF TEXT 2
LINE OF TEXT 1
LINE OF TEXT 2
LINE OF TEXT 3
I want to find "LINE OF TEXT 3" which comes after "LINE OF TEXT 2" which in turn comes after "LINE OF TEXT 1" (with no empty lines in between).
Each line must be a regexp itself, for example a line starts with "LINE" and ends with a particular number.
Note: Not all files contain that exact line sequence, so if a pattern match then don't print the pattern but just print the filename to STDOUT.
Can this be done in a one-liner regexp? So, for example, awk searches a pattern in a file and prints filename to STDOUT if a pattern found. I then can use this regexp in a combination with "find -exec".
Any mentioned tool will go (grep, awk, sed or perl).