如何用sed替换整行? [英] How to replace a whole line with sed?
本文介绍了如何用sed替换整行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个带行的文件
Suppose I have a file with lines
aaa=bbb
现在我想将它们替换为:
Now I would like to replace them with:
aaa=xxx
我可以这样做:
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]
如何使用 sed 将 all 这行 aaa=[something]
替换为 aaa=xxx
?
How can I replace all this lines aaa=[something]
with aaa=xxx
using sed?
推荐答案
试试这个:
sed "s/aaa=.*/aaa=xxx/g"
这篇关于如何用sed替换整行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文