Fixing "sed: command i expects \ followed by text" error

I ran into a very weird error today. While trying to automate the deployment for this blog, I needed to replace a string in a file. The internet tutorials [1, 2, 3, 4] told me that sed would be perfect for this job and the following command should work: sed -i 's/search_string/replace_string/' filename The Error However, I kept getting tripped up by the following error: sed: 1: "i2.html": command i expects \ followed by text I spent a bunch of time trying to make sure I escaped the right characters in my strings but the error was persistent!...

December 10, 2020 · 2 min · Kay Singh