I am new to the regular expression paradigm and I've encountered a problem I'm trying to solve, with no success.
Imagine a file test.txt with:
hello everyone, whatsi up
i hope my program worksa
if it doesnt... ho well!
I would like to output to another file output.txt only the words that start with a consonant and end with a vowel so it would result in:
hello whatsi
hope worksa
ho
I am using grep -o '\b[^ aeiouAEIOU]\w*[aeiouAEIOU]\b' test.txt > output.txt however, the -o flag outputs every matched string onto a new line. What should I do to get the format that I want? Another valid option would be to substitute everything that doesn't match that pattern with a blank space using sed but I failed to do it as well. Should I be using sed or awk instead?
Thanks