Skip to content

Instantly share code, notes, and snippets.

@maxwofford
Created September 21, 2014 22:40
Show Gist options
  • Save maxwofford/1654a998dd59148af68a to your computer and use it in GitHub Desktop.
Save maxwofford/1654a998dd59148af68a to your computer and use it in GitHub Desktop.
Replace key words in a file
# Replaces words in input.txt
# Takes arguments in the format foo='bar'
input = File.open('input.txt', "w")
ARGV.each do |i|
variable_name = i.to_s.split('=')[0]
contents = .to_s.split('=')[1]
input.gsub(variable_name, contents)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment