I have a pretty big json file and I would like to add the escape character in front of all quotation marks in it. For example I want to change: "CaptureDuration":0 to \"CaptureDuration\":0. I tried to substitute all " with \" in sed and vim but I guess due to the special type of the escape character it wasn't working properly.

1 Answer 1


Use sed and you needed to escape \ as it's special character:

sed 's/"/\\"/g' infile
  • 1
    it works, thanks a lot for the quick reply Commented Apr 4, 2018 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .