Filter all lines that contain words with two vowels (grep)?

2.2k views Asked by At

I want to use grep to sort all lines from a file that contain any two vowels one after each other. For example if I have the next file

aab aeb baaa
eg gefee xxe
xx a axa

I want to keep only the first two lines because they contain 2 vowels. I just can't figure out the right regular expression for this. It should work with any combination (aa, ae, ai, ao, .., ee etc)

2

There are 2 answers

0
tripleee On

Depending on which letters count as vowels in your language, something like

[aeiou][aeiou]

If you have graphemes which are only sometimes vocalic (like y in English -- a vowel in "try" but a consonant in "yet") you will need something singnificantly more sophisticated; from your examples, it looks like maybe this is sufficient.

2
jimm-cl On

For the data set in your example, the following grep command will give you the results you are looking for:

grep -e ".*[aeiou][aeiou].*" foo.txt
aab aeb baaa
eg gefee xxe