问题
I am trying to delete all words that start with a vowel as per below. The sed command I have is only deleting the first word if it has a vowel, not any others. I thought the boundary marker below and using the g
would capture all words but it is not doing it. How do I get it to get all words with vowels ?
echo "Always take a Big Apple " | sed -r 's/\b^[AEIOUaeiou]\w*//g'
回答1:
Remove ^
sed -r 's/\b[AEIOUaeiou]\w*//g'
you don't need to anchor it to the beginning of line, enough that you request it to be on the word boundary.
回答2:
echo "Always take a Big Apple " | sed -r 's/\b[AEIOUaeiou]\w*//g'
回答3:
This GNU sed solution might work for you:
echo "Always take a Big Apple " | sed 's/\<[aeiou]\w*//Ig'
来源:https://stackoverflow.com/questions/8429049/sed-delete-only-words-with-vowels