I want to use sed to replace every '} that comes at the end of the line to "}. I wrote:

sed -i -e "s/'}$/\"}$/g"

But this replaces it to: "}$. What is wrong? How can I use regex in my sed to express beginning and end of line using ^ and $


Only the search expression is a regex, the replacement text isn’t:

sed -i -e "s/'}$/\"}/g"

This matches '} at the end of a line, and replaces it with "}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.