I'm trying to detect a pattern that has three parts:
- A space
- Either an "m" or a "t"
- Either a space or the end of a line
I want to keep #2 and #3. For example, I'd like to change "i m sure he doesn t" to "im sure he doesnt"
I'm having trouble expressing #3, since [ $]
only seems to match spaces, not line-ends. Here's what I've tried:
$ echo "i m sure he doesn t" | sed 's/ \([mt]\)\([ $]\)/\1\2/g'
im sure he doesn t
How should I express "either a space or end of line" in the expression above? Thanks!