How to replace a whole line with sed?

后端 未结 6 1795
故里飘歌
故里飘歌 2020-12-07 10:59

Suppose I have a file with lines

aaa=bbb

Now I would like to replace them with:

aaa=xxx

I can do that as follows:

sed \"s         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 11:43

    Like this:

    sed 's/aaa=.*/aaa=xxx/'
    

    If you want to guarantee that the aaa= is at the start of the line, make it:

    sed 's/^aaa=.*/aaa=xxx/'
    

提交回复
热议问题