Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2015 13:27
Show Gist options
  • Save anonymous/918cd60ee21471bd8477 to your computer and use it in GitHub Desktop.
Save anonymous/918cd60ee21471bd8477 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 ( IDS.any? { |w| line =~ /#{w}/ } ) && line =~ /INSERT INTO|DELETE|UPDATE|INSERT_ID/
puts line
ID = line.split(' ').find {|item| IDS.include? item }
new_ID = ID.to_i + 1000
line.gsub(/#{ID}/,'#{newID}')
puts line
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment