Question

I have a json file, which contains the following for example:

"images": [
    ".images/phones/motorola-xoom.0.jpg", 
    ".images/phones/motorola-xoom.1.jpg", 
    ".images/phones/motorola-xoom.2.jpg"
],

Using git bash on Windows and sed I am trying to substitute .images with ./images. I thought of using sed -i 's/.images/.\/images/g' filename.json however when doing that sed selects and replaces the first instance of "images" as well. Why is that and how should I modify file my sed command? Thx

Was it helpful?

Solution

Escape the dot .. As . means "anything", you have to escape it to make it mean just .:

$ sed 's/\.images/.\/images/g' file
"images": [
    "./images/phones/motorola-xoom.0.jpg", 
    "./images/phones/motorola-xoom.1.jpg", 
    "./images/phones/motorola-xoom.2.jpg"
],
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top