Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么 echo 'word word word word word word' | sed 's/[a-zA-Z]* /DELETED /2g'
echo 'word word word word word word' | sed 's/[a-zA-Z]* /DELETED /2g'
打印word DELETED DELETED DELETED DELETED word?
word DELETED DELETED DELETED DELETED word
为什么sed没有替换最后一个word?
word
因为您的正则表达式有一个尾随空格:
/[a-zA-Z]* / ^
它明确地搜索零个或多个字母,后跟一个空格。