I am trying to find a way to grep/awk multiple patterns and then print a certain number of lines below the first pattern and a certain number of lines below the second pattern. For example
....
other lines
....
###Pattern 1####
line 1
line 2
line 3
....
other lines
....
####Pattern 2####
line 1
line 2
line 3
line 4
....
other lines
....
So what I want to do is find the two patterns in the file and print out the first pattern and the 3 preceding lines underneath, then the second pattern and the four preceding lines underneath the second pattern.
So that my desired output looks like:
####Pattern 1####
line 1
line 2
line 3
####Pattern 2####
line 1
line 2
line 3
line 4
Updated Desired Output So before I wasn't as clear I apologize, there may be multiple patterns. So what I would hope to achieve is an output that looks like the following:
####Pattern 1####
line 1
line 2
line 3
####Pattern 2####
line 1
line 2
line 3
line 4
-----
####Pattern 1####
line 1
line 2
line 3
####Pattern 2####
line 1
line 2
line 3
line 4
-----
and so on