Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2015 08:05
Show Gist options
  • Save anonymous/386e9f03f859cdb4c692 to your computer and use it in GitHub Desktop.
Save anonymous/386e9f03f859cdb4c692 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=""
file2 = open("dump-to-database-test-1", 'w')
File.open("test.sql").each do |line|
if ( id = ids.find { |w| line =~ /\b#{w}\b/ } )
new_id = id.to_i + 1000
line.gsub!(/\b#{id}\b/,"#{new_id}")
file2.write(line)
else
file2.write(line)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment