I'm trying to find how to search for two strings in a text file within n lines of each other. For example, given the file:
abc def
ssssss
ssssss
ssssss
ssssss
ssssss
pqr xyz
I want "myscript abc pqr 5" to return nothing but "myscript abc pqr 7 (or greater)" to return the filename in which it was found and (bonus) the matching lines and the intervening ones. It should work with any strings.
Just to make it interesting, I'm working on Solaris 10 and do not have access to any gnu commands or extensions. It's like swimming in treacle.
TIA
Nigel.