From OS X CLI, read file and return only valid English dictionary words?

44 Views Asked by At

Question

From an OS X command line, how can I check a list of strings from an input file (one string per line) and filter out the strings that are not valid dictionary words? For example, if the input were...

z3b8U
z6kgvhG3AkI
zealot
zealotry

...the output should return...

zealot
zealotry

Context

I'm trying to parse an input file (an ebook in text format) and get a list of the unique valid words. So far, I have the following to get all the unique strings in the file...

$ tr -cs '[:alnum:]' '\n' < input.txt | sort -u

I have the the dict command installed via Homebrew, but I haven't found an easy incantation that just filters out the invalid words and returns the valid ones.

0

There are 0 best solutions below