Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

regex - How to replace a whole line with sed?

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/aaa=bbb/aaa=xxx/g"

Now I have a file with a few lines as follows:

aaa=bbb
aaa=ccc
aaa=ddd
aaa=[something else]

How can I replace all this lines aaa=[something] with aaa=xxx using sed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:

sed "s/aaa=.*/aaa=xxx/g"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...