how to replace quenstion mark in sed

how to replace quenstion mark in sed

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.

Enjoyed this article?

Check out more content on our blog or follow us on social media.

Browse more articles