I have a large text file. I’d like to pick out strings of form
(1, 2, 4, ...)
which is followed by string “foobar”. Both of these two strings can appear on multiple lines. How to do this quickly on UNIX command line?
Example
(1, 2) foobar
foobar (3, 4, 5) foobar (23, 45)
(6,
7, 8) foobar
(9, 10, 11) foo
bar
should give
(1, 2)
(3, 4, 5)
(6, 7, 8)
(9, 10, 11)
1 Answer