Quantcast
Channel: Show all lines before a match - Ask Ubuntu
Viewing all articles
Browse latest Browse all 8

Show all lines before a match

$
0
0

I want to show all lines before a match, not only 10, or 7, or 14 for example, as explained in How do I fetch lines before/after the grep result in bash?.

How can I do it? It doesn't matter if the matched line is included or not.

For example, instead of:

... | grep -B 10 -- "foo"

I want:

... | grep -B -- "foo"

But this last code doesn't work.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>