Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2015 13:55
Show Gist options
  • Save anonymous/05f67b7f40c695bd0d67 to your computer and use it in GitHub Desktop.
Save anonymous/05f67b7f40c695bd0d67 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
IDS=[]
IDS_t=[]
IDS_t = File.readlines("id_to_change_uniq")
IDS=IDS_t.map(&:chomp)
new_ID=""
File.open("binlog-restore-20150614-1230-ruby").each do |line|
if line =~ /INSERT INTO|DELETE|UPDATE|INSERT_ID/
ID = IDS.find { |w| line =~ /#{w}/ }
puts line
p ID
new_ID = ID.to_i + 1000
p new_ID
line.gsub(/#{ID}/,"#{new_ID}")
puts line
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment