I was modifying a file using sed, all went well except a line, similar lines were ok but the one line.

i did lot of changes to sed but no use it keeps yelling at me

sed: -e expression #1, char 91: unterminated `s' command

Here is my piece of code:

VAR=$(FUNC string)
sed -i "s/^Name .*.*/Name $VAR/" /etc/file.conf

Spent lot of time and what i found finally was, usually sed uses "s" as a separator, here the string i was supplying to function FUNC has a letter "s", in fact "VAR" doesn't have anything "s" in it.
Truth is while substituting sed sees letter "s" in the string i was supplying to the function as a separator and throws an error.

So i used fuction call as variable here to get what i want so to solve the issue.

sed -i "s/^Name .*.*/Name $(FUNC string)/" /etc/file.conf

Source:

gil...