Quantcast
Viewing all articles
Browse latest Browse all 8

Answer by user.dz for Show all lines before a match

FreeBSD (including MacOS) version does have such feature.

Well -B -1 works, it shows all the lines before the match from the beginning of the file.

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

Same for -A -1 , it shows all the lines after the match to the end of the file.

... | grep -A -1 -- "foo"

May be useful for some, It doesn't work with GNU implementation included within Ubuntu.


Viewing all articles
Browse latest Browse all 8

Trending Articles



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