I am trying to find a way to replace the entire line that matches a given string in a lot of files. The line will have a random value that I need to replace but will end with the string '; Serial'. The replacement will be the same for all files.
What I am trying to do is replace the zone serial number in the bind zone files. I am migrating to a new host IP so have updated all the IP addresses. Now I want to update the serial so I don't have to edit by hand hundreds of files.
Here is a sampling of the values:
#grep -i -e '; Serial' *
domain1.db: 2008092501 ; Serial
domain2.db: 2013040901 ; Serial
domain3.db: 2012051901 ; Serial
domain4.db: 2012123101 ; Serial
domain5.db: 2012072601 ; Serial
And I want to replace them all with:
20131215 ; Serial
I am sure there is a way to do this with sed or similar script but I have not been able to find a way thus far.