Categories
Linux Mastering Development Ubuntu

grep: Show ALL lines before a match

Not only 10, or 7, or 14 for example, as explain in this topic and in many others:
https://stackoverflow.com/questions/12444808/how-do-i-fetch-lines-before-after-the-grep-result-in-bash/12444813
How you do it?

For example, instead of:

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

I want:

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

But this last code doesn’t work.

Leave a Reply

Your email address will not be published. Required fields are marked *