Last active
July 29, 2020 23:04
-
-
Save jjam3774/ec0bfde8b66013e0a52b to your computer and use it in GitHub Desktop.
Changing files and creating a backup of 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