Sed Error Unknown option to 's' + Solution

This is post is now quite old and the the information it contains may be out of date or innacurate.

If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub

If you are struggling to figure out why your Sed script is failing this could well be the solution.

Every example you see using sed specifies / as a delimiter.

Now what if your pattern actually includes a slash in the body text?

If you are using a variable you might not realise that you are including a slash.

Easy thing to do, just switch the delimiter to something else like #

so

sed "s/find/$REPLACE/" 

becomes

sed "s#find#$REPLACE#"

and hey presto it works!


Tags: linuxerroroptionbashsedscriptunknowndelimiter