how to replace quenstion mark in sed

how to replace quenstion mark in sed
typescript
Ethan Jackson

I want to replace a? with b? where ? is a character, not wildcard. Here is what i try:

echo "a?c" | sed 's/a\?/b?/'

I expect b?c, but it returns b??c. I also tried two backslashes between a and ?, it doesn't work either.

Answer

thanks to Cyrus and derpirscher, by default ? in sed is not a wildcard, use \? to use it as traditional regex wildcard.

Related Articles