Sed – unknown option to `s'


I execute a sed command in my script:

sed -i "${1}s/${2}=.*/${2}=${REPLY}/" $3

this is the echo:

sed -i 13s/log4j.appender.ROOT2.File=.*/log4j.appender.ROOT2.File=/app/TET/log.log/ /applis/DIAPASON/diapason1/conf/log4j.properties

My error:

sed: -e expression n°1, character 61: unknown option fors`’

One Response to “Sed – unknown option to `s'”

  1. John says:

    You have multiple ‘/’ charachters inside the ${REPLY} variable, which is confusing sed. You can choose an alternate delimiter for the s/// command in most versions of sed, so if this were me, I’d try something like:
    sed -i "${1}s|${2}=.*|${2}=${REPLY}|" $3. This replaces the ‘/’ for sed with ‘|’, so that the ‘/’ in ${REPLY} are (hopefully) not interpreted by sed.

Leave a Reply

You must be logged in to post a comment.

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam