[英]Replace with sed after the first occurence of specific word - Linux/Ubuntu
Original file: 原始文件:
bla bla test
blabla
start
test
blabla
start
test
The result should be: 结果应为:
bla bla test
blabla
start
edit
blabla
start
edit
So after the first occurence of "start" all "test" should be replaced with "edit" 因此,在首次出现“开始”之后,所有“测试”都应替换为“编辑”
You can use this sed: 您可以使用此sed:
sed '/start/,$s/test/edit/g' file
bla bla test
blabla
start
edit
blabla
start
edit
Explanation: 说明:
/start/,$ # find text from first occurrance of start till end
s/test/edit/g # in the found text replace test by edit globally
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.