search

Home  >  Q&A  >  body text

sed替换两个符号之间的内容为别的内容怎么写

1

2

3

4

5

6

7

8

{

    "port_password":{

       "2016":"helloss",

       "1027":"wwwcc"

    },

    "method":"aes-256-cfb",

    "timeout":600

}

要把第三行中的helloss替换成haha可以下面这样
sed -i 's/helloss/haha/g` filename
但是helloss是不确定的,我只是想把第三行第二对双引号之间的内容替换成haha,应该怎么写啊

高洛峰高洛峰3094 days ago1080

reply all(2)I'll reply

  • 欧阳克

    欧阳克2016-11-11 11:08:53

    v2ex的@Strikeactor提供的

    1

    sed 's/"2016":".*"/"2016":"haha"/' filename


    reply
    0
  • 三叔

    三叔2016-11-11 11:08:30

    为什么不 parse 呢?

    reply
    0
  • Cancelreply