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 '/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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.