sed - delete only words with vowels

﹥>﹥吖頭↗ 提交于 2019-12-11 02:55:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!