0

I am trying to use awk to find a pattern, then print the line X amount of lines below it. For example:

This a line of something I dont need
More of what I dont need
This is what I want to print    # <-- This contains the same information of what I want to print, but I do not want to print this line.
This is the pattern I need to find
This is unimportant
So is this
This too
As well as this
This is what I want to print    # <-- This is the line I actually want to print

Notice how the same thing I want to print comes up multiple times, which is why I need to only print it when it comes after the pattern I define. So, theoretically, I would put the afformentioned text into awk and get:

This is what I want to print    # <-- This is the line I actually want to print

That is occurrence of This is what I want to print after the pattern I defined.

I don't really know what I'm doing when comes to regex and awk, so I don't even know if this is possible. If it is not possible with these tools, then is there a way to do this at all?

PS: I am using this in a script that gives information about one of my audio sinks. There are many sinks, that all have the same information fields. So, I am searching for the sink I want, then printing a certain field which comes after the name of the sink. I hope this makes sense.

nswerhun
  • 144
  • 8

0 Answers0