Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2015 13:02
Show Gist options
  • Save anonymous/34c76808b15f9eb0b80b to your computer and use it in GitHub Desktop.
Save anonymous/34c76808b15f9eb0b80b to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
IDS=[]
IDS = File.readlines("id_to_change_uniq")
new_ID=""
File.open("binlog-restore-20150614-1230-ruby").each do |line|
if ( IDS.any? { |w| line =~ /#{w}/ } ) && ((line =~ /INSERT INTO/) || (line =~ /DELETE/) || (line =~ /UPDATE/) || (line =~ /INSERT_ID/))
ID=line.split(' ') & IDS
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