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?
I’m using the operating systems dictionary file to scan. I’m creating a java program
Share
To find words that contain only the given letters:
The above filters out the lines in
wordlistthat 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: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:
(Yes, there is a useless use of
catabove, but the symmetry is better this way.)