complicated pattern matching with awk or sed...
I want to do pattern matching with awk or sed but I don't know how. here's what I want:
I have a line number for a pattern that I have already found using grep, and I know a pattern like "---" that happens a few lines above that certain line number. I want to print out the chunk between "---" and that line number. But here's the catch. the pattern "---" can be between 1 and 20 lines above that line number and I don't know how many lines above ... Also, another catch is that, "---" can happen multiple times in the file but I want the "CLOSEST" to the line number. Here's an example:
Here's the file:
Can someone help me out here please?
Not sure if there's such an easy way with sed. It would be simple in awk, but I'm going to give you a little perl script to do it instead.
|All times are GMT -5. The time now is 04:51 PM.|