I am trying to exclude certain words from dictionary file.
# cat en.txt
test
testing
access/p
batch
batch/n
batches
cross
# cat exclude.txt
test
batch
# grep -vf exclude.txt en.txt
access/p
cross
The words like "testing" and "batches" should be included in the results.
expected result:
testing
access/p
batches
cross
Because the word "batch" may or may not be followed by a slash "/". There can be one or more tags after slash (n in this case). But the word "batches" is a different word and should not match with "batch".
Using grep matching whole words:
Explanation (from man grep)
-w--word-regexpSelect only those lines containing matches that form whole words.-v--invert-matchInvert the sense of matching, to select non-matching lines.-f-f FILEObtain patterns from FILE, one per line.Output