sed: -e expression #1, char NN: unknown option to `s'

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.


sed: -e expression #1, char 49: unknown option to `s'

Example code producing this error:
sed "s/<[^<]*[^>]*>\([^<]*\)</a>/\1/g"

check for un-escaped forward slashes. Above, the slash in </a> is unescaped. Everything coming after the third slash is considered to be options for s, like the final 'g' is intended to be.
Either escape the slashes:

sed "s/<[^<]*[^>]*>\([^<]*\)<\/a>/\1/g"

Or use a different delimiter, e.g. '#':
sed "s#<[^<]*[^>]*>#([^<]*\)</a>#\1/g"