Created
March 10, 2022 19:48
-
-
Save agilous/24ceff7ab86549bedca2eaaca00db591 to your computer and use it in GitHub Desktop.
Short Ruby script that permits dynamic replacement of text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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