sed error: “invalid reference \1 on `s’ command’s RHS”

Don’t you need to actually capture for that to work? i.e. for variant #2:

-r -e "s/WARNING: (\([a-zA-Z0-9./\\ :-]\+\))/${warn}WARNING: \1${c_end}/g" \

(Note: untested)

Without the -r argument back-references (like \1) won’t work unless each parenthesis is escaped with a \ character.

With -r, argument back-references (like \1) won’t work unless the parenthesis are NOT escaped.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)