Last active
July 29, 2020 23:04
-
-
Save jjam3774/7a56388df47b74fc58a1 to your computer and use it in GitHub Desktop.
This will replace strings in a file.
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
#!/usr/bin/ruby -w | |
def replace_ref(file, fileindx, &directive) | |
old_stdout = $stdout | |
argf = ARGF.clone | |
argf.argv.replace [file] | |
argf.inplace_mode = fileindx | |
argf.each_line() { |line| | |
yield line | |
} | |
$stdout = old_stdout | |
end | |
File.open('files').each { | |
|i| | |
puts i | |
begin | |
replace_ref i.chomp, '.bk' do |line| | |
puts i + " Is being changed..." | |
line = line.gsub(/\/common\/js\/extern\/omniture\/s_code.js/,"/js/extern/omniture/s_code.js") | |
print line | |
end | |
rescue | |
puts i.chomp + " Does not exist...".upcase | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment