Given a file like
asdasd
123
X
456
X
789
asd
asd
asd
asd
If I run grep: grep -C3 'X'
on the above, I get the following results
asdasd
123
X
456
--
456
X
789
asd
asd
It appears that grep only shows the context of each match up to the previous or following match. Is there a way to get it to display the entire context regardless of whether the pattern is contained in it? Looking at man grep
, there seems to be no such option. The expected result is as follows:
asdasd
123
X
456
X
789
--
123
X
456
X
789
asd
asd
grep --version
report? The (admittedly very old) Mac I just tried came with GNU grep 2.5.1, which produces something else again (the first 8 lines of the file, with no--
). – JigglyNaga Nov 20 '18 at 10:10grep --version
reports "grep (BSD grep) 2.5.1-FreeBSD". Running on MacOS Mojave Version 10.14 – kanghj91 Nov 21 '18 at 01:56