Saturday, February 5, 2022

[SOLVED] Unix grep duplicate vowels search

Issue

I am stuck on a homework question. The question asks to display the lines, with grep and I can't use -w option, that contain no duplicate vowels.

My teacher said to find the grep command that could display two or more 'a's in a line which would, I think, be grep 'a.*a' file and then find the grep command that would display two or more 'u's which, I think, would be grep 'u.*u' file, combine them and then I should be able to get it. But I don't know how I would combine the grep commands.


Solution

You can combine different regular expressions with |:

grep 'a.*a|e.*e|i.*i|o.*o|u.*u' file


Answered By - clemens
Answer Checked By - Candace Johnson (WPSolving Volunteer)