For example, i have file with contenthello worldit's nice to see youamazing nightwhat a wonderful daymy name is Robertstill breathingspeaking bottom soulsomething wrongI need to match those lines, in which second word has exactly two vowels.So the output should be:it's nice to see youmy name is Robertspeaking bottom soulHow can I do this using grep?
Grep template for extracting lines where second word has only two vowels
grep;regular expression
grep with extended regular expressions:grep -iE '^[^[:blank:]]+[[:blank:]]+([^aeiou]*[aeiou]){2}[^aeiou]*\>' filegrep with pcregrep -iP '^\S+\s+([^aeiou]*[aeiou]){2}[^aeiou]*\b' fileperl (honestly, I did this independent of steeldriver's comment)perl -ane 'print if (lc($F[1]) =~ tr/aeiou/aeiou/) == 2' fileawkawk '{col2 = tolower($2); gsub(/[aeiou]/,,col2)} length($2) - length(col2) == 2' file