Reputation: 26415
Why echo 'word word word word word word' | sed 's/[a-zA-Z]* /DELETED /2g'
prints word DELETED DELETED DELETED DELETED word
?
Why sed didn't substitute the last word
?
Upvotes: 0
Views: 694
Reputation: 281505
Because your regular expression has a trailing space:
/[a-zA-Z]* /
^
It's explicitly searching for zero or more letters followed by a space.
Upvotes: 4