I am removing stop words from a text, roughly using this code
I have the following
$ cat file
file
types
extensions
$ cat stopwords
i
file
types
grep -vwFf stopwords file
I am expecting the result:
extensions
but I get the ( I think incorrect)
file
extensions
It is as if the word file
has been skipped in the stopwords file.
Now here's the cool bit: if I modify the stopwords file, by changing the single word/letter i
on the first line, to any other ascii letter apart from f
, i
, l
, e
, then the same grep command gives me a different and correct result of extensions
.
What is going on here and how do I fix it?
I'm using grep (BSD grep) 2.5.1-FreeBSD on a Mac OSX GNU bash, version 4.4.12(1)
-x
switch for line regex instead of-w
for word? However I think the-F
switch will cancel either of them out, or vice-versa.i
pattern the second rather than the first pattern in thestopwords
file also alters the behaviour.grep
nor with GNUgrep
3.1.