Trying find and replace with the following code:
#!/usr/bin/env ruby
file_names = [‘foo.txt’]
file_names.each do |file_name|
text = File.read(file_name)
new_contents = text.gsub(/ADMIN_URL="t3:./,
'ADMIN_URL="t3s://hostname -f
.’)
To merely print the contents of the file, use:
puts new_contents
# To write changes to the file, use:
File.open(file_name, "w") {|file| file.puts new_contents }
end
But command substitution is not happening. Not sure what is the issue
here. Any help?