Skip to content

Instantly share code, notes, and snippets.

@agilous
Created March 10, 2022 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agilous/24ceff7ab86549bedca2eaaca00db591 to your computer and use it in GitHub Desktop.
Save agilous/24ceff7ab86549bedca2eaaca00db591 to your computer and use it in GitHub Desktop.
Short Ruby script that permits dynamic replacement of text
file_name = 'errors.sql'
error_number = 50_001
lines = IO.readlines(file_name)
lines.each_with_index do |line, index|
next unless line[/99999/]
lines[index] = line.gsub('99999', error_number.to_s)
error_number += 1
end
File.write(file_name, lines.join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment