I am trying to match keywords listed in one file from text in another file. The keywords file is new line separated.
grep returns different results based on the order of the keywords (not the input file).
Here is an example.
With this input
# input.txt
TRITONS, sea-deities; they sung the marriage chorus of ACHILLES.
Case 1
# terms.txt
ACHILLES
TRITONS
# grep returns just one match
grep -o -f terms.txt input.txt
ACHILLES
Case 2: I just changed the order of the keywords file
# terms.txt
TRITONS
ACHILLES
# grep returns both matches !
grep -o -f terms.txt input.txt
TRITONS
ACHILLES
Trying to understand the behavior.