user10557615
user10557615

Reputation:

How to find only the lines that contain two consecutive vowels

how to find lines that contain consecutive vowels

$ (filename) | sed '/[a*e*i*o*u]/!d'

Upvotes: 1

Views: 1038

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627087

To find lines that contain consecutive vowels you should consider using

sed -n '/[aeiou]\{2,\}/p' file

Here, [aeiou]\{2,\} pattern matches 2 or more occurrences (\{2,\} is an interval quantifier with the minimum occurrence number set to 2) and [aeiou] is a bracket expression matching any char defined in it.

The -n suppresses output, and the p command prints specific lines only (that is, -n with p only outputs the lines that match your pattern).

Or, you may get the same functionality with grep:

grep '[aeiou]\{2,\}' file
grep -E '[aeiou]{2,}' file

Here is an online demo:

s="My boomerang
Text here
Koala there"
sed -n '/[aeiou]\{2,\}/p' <<< "$s"

Output:

My boomerang
Koala there

Upvotes: 1

Related Questions