【发布时间】:2016-08-07 07:19:06
【问题描述】:
我的文字如下所示
this This that
it It Its
my My Mine
this This that
it It Its
my My Mine
我想替换第一个匹配项的第一行。例如。匹配包含my 的行,然后替换该行。我做了
cat txt|sed "0,/my/c\my changed line" txt
打印出来如下图,前两行被剪掉了。
my changed line
this This that
it It Its
my My Mine
如果我运行这个cat txt|sed "s/my/changeline/" txt
输出如下
this This that
it It Its
changeline My Mine
this This that
it It Its
changeline My Mine
我怎样才能得到如下结果?
this This that
it It Its
changeline My Mine
this This that
it It Its
my My Mine
【问题讨论】: