9
rated 0 times
[
9]
[
0]
/ answers: 1 / hits: 10560
/ 3 Years ago, sun, may 30, 2021, 9:13:17
Is it possible, using grep, to search for instances of John Smith
but exclude instances of Mr John Smith
?
More From » grep
Is it possible, using grep, to search for instances of John Smith
but exclude instances of Mr John Smith
?
This could be solved using a regular expression with negative lookbehind (which is experimentally supported in grep
as pointed out by the comment from arrange):
$ grep -P '(?<!Mr )John Smith' file
Since the support is just experimental, you might want to use perl
instead:
$ perl -nle 'print if /(?<!Mr )John Smith/' file