GREP How do I search for words that contain specific letters (one or more times)?
grep
Solution
To find words that contain only the given letters:
grep -v '[^aeiou]' wordlist
The above filters out the lines in `wordlist` that don't contain any characters except for those listed. It's sort of using a double negative to get what you want. Another way to do this would be:
grep '^[aeiou]+$' wordlist
which searches the whole line for a sequence of one or more of the selected letters.
To find words that contain all of the given letters is a bit more lengthy, because there may be other letters in between the ones we want:
cat wordlist | grep a | grep e | grep i | grep o | grep u
(Yes, there is a useless use of `cat` above, but the symmetry is better this way.)
Problem
I'm using the operating systems dictionary file to scan. I'm creating a java program to allow a user to enter any concoction of letters to find words that contain those letters. How would I do this using grep commands?