Argh. 30+ zone files and I have to increment all numbers by hand…no way.

Usage:  ./inc.rb in the current directory with all db files.

#!/usr/bin/ruby

Dir.glob("*.db") do |file_name|
 new_zone = []
 File.open(file_name) do |file|
 while (line = file.gets)
 line.chomp!
 if line =~ /Serial/
 line =~ /(\s*?)(\d+)(\s*?)(;.*)/
 serial = $2.to_i
 serial += 1
 puts "#{file_name} serial line:  #{$1} #{$2} #{$3} #{$4} -> #{$1}#{serial}#{$3}#{$4}"
 line = "#{$1}#{serial}#{$3}#{$4}"
 end
 new_zone << line
 end
 end

 File.open(file_name, "w") do |new_file|
 new_file.write(new_zone.join("\n"));
 end
end