Jerryleo
asked on
Replacing a block of text in a file with sed
I need to locate and replace a block of text in a file daily.
for example,
....locate following block
start_year = 2004
start_month = 12
start_day = 31
start_hour = 00
end_year = 2005
end_month = 01
end_day = 02
end_hour = 12
.... and replace it with this:
start_year = 2005
start_month = 01
start_day = 01
start_hour = 00
end_year = 2005
end_month = 01
end_day = 03
end_hour = 12
Surely I don't have to do a line-by-line replacement. It seems like I should be able to pick a beginning and ending element, and choose to replace everything in between... I don't know how to deal with a block in sed, any ideas....?
Thanks in advance
for example,
....locate following block
start_year = 2004
start_month = 12
start_day = 31
start_hour = 00
end_year = 2005
end_month = 01
end_day = 02
end_hour = 12
.... and replace it with this:
start_year = 2005
start_month = 01
start_day = 01
start_hour = 00
end_year = 2005
end_month = 01
end_day = 03
end_hour = 12
Surely I don't have to do a line-by-line replacement. It seems like I should be able to pick a beginning and ending element, and choose to replace everything in between... I don't know how to deal with a block in sed, any ideas....?
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.