On Wednesday, May 23, 2012 3:13:05 AM UTC-5, Guillaume Dargaud wrote:
> I have a list of words and a file that contains some of those words (and
> plenty more). I want the list of words which aren't in the file... I've been
> playing around with grep for 5 minutes without success...
Here is one way, using 2 steps:
1. Convert the textfile to a glossary of each word found in the text file. A very rough way to do it is like this (this may "wrap", but it should be on one line):
perl -pe 's/[[:punct:]]*\s+[[:punct:]]*/\n/g' textfile | sort -u >glossary
2a. To find words in the wordlist that are NOT in the glossary:
fgrep -of wordlist glossary | sort -u | fgrep -vf - wordlist
2b. To find words in the wordlist that ARE in the glossary:
fgrep -of wordlist glossary | sort -u | fgrep -f - wordlist
Hope this helps