Reputation: 35
I want to replace with sed in some bash script something like:
s:44:\"STRING\"
To:
s:NEWSTRING:\"NEWSTRING2\"
I tried many ways with escaping special characters, but I got always error
sed: -e expression #1, char 32: unterminated
s' command`
or someting like that.
Can you please tell me the correct sed -i (sed -i "s/xxx/xxx/g" file) command for that?
Upvotes: 0
Views: 144
Reputation: 7499
You have to escape the backslashes properly:
sed 's/s:44:\\"STRING\\"/s:NEWSTRING:\\"NEWSTRING2\\"/'
Example:
$ echo 's:44:\"STRING\"' | sed 's/s:44:\\"STRING\\"/s:NEWSTRING:\\"NEWSTRING2\\"/g'
s:NEWSTRING:\"NEWSTRING2\"
Upvotes: 1
Reputation: 371
You are missing the final delimiter. In your case it seems to be : therefore, you need to add a final : after your substitution content. It does not matter if you are using modification instruction like g
Upvotes: 0