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
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"
],
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.