Artificial intelligent assistant

sed find replace issue 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?

Try this:


sed -i -e "s/headers\['Content-Disposition'\] = \"attachment; filename=%s\" % (filename)/headers\['Content-Disposition'\] = 'attachment; filename=\"%s\"' % (filename)/g" test.txt

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy b04abbd85546f2e3f9850b238230b6a8