This is the output for my command:
abstemious abstemiously abstemiousness abstemiousness's abstemiousnesses abstentious arsenious caesious facetious facetiously facetiousness facetiousness's facetiousnesses ultraserious
But the correct output is:
abstemious abstemiously abstentious arsenious caesious facetious facetiously
My command is:
grep -E [^aeiou]*[a]{1}[^aeiou]*[e]{1}[^aeiou]*[i]{1}[^aeiou]*[o]{1}[^aeiou]*[u]{1}[^aeiou]* dictionary.txt
I want to find out all words in dictionary.txt is 'aeiou',in that order,and no other vowels. But I can't find anything wrong with my command right now, I need a little hint. Thanks in advance for helping me find the error
CodePudding user response:
Use the ^
and $
to match from the beginning to the end of each line, respectively (not allowing a partial substring match for each):
grep -E ^[^aeiou]*[a]{1}[^aeiou]*[e]{1}[^aeiou]*[i]{1}[^aeiou]*[o]{1}[^aeiou]*[u]{1}[^aeiou]*$ dictionary.txt
CodePudding user response:
You need to break the searches into words by delimiting with the word boundary character \b
. i.e.
\b[^aeiou]*[a]{1}[^aeiou]*[e]{1}[^aeiou]*[i]{1}[^aeiou]*[o]{1}[^aeiou]*[u]{1}[^aeiou]*\b