I want to replace
headers['Content-Disposition'] = "attachment; filename=%s" % (filename)
with
headers['Content-Disposition'] = 'attachment; filename="%s"' % (filename)
(so that the "%s" is double-quoted).
My best effort so far is
sed -i -e 's/"headers[\'Content-Disposition\'] = \"attachment\; filename=%s\" % \(filename\)"/"headers[\'Content-Disposition\'] = \'attachment\; filename=\"%s\"\' % \(filename\)"/g' test.txt
but it fails:
sed: -e expression #1, char 33: unterminated `s' command
I tried all that I could come across on stackoverflow and elsewhere. I tried escaping the quotes as well. But this too much of single and double quotes is causing errors.
I have scanned the line and I'm sure I haven't left any unterminated quotes. How can I get it working?
sed -e "s/\"/'/g" -e 's/%s/"%s"/'
?