Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created January 8, 2013 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chewmanfoo/4485800 to your computer and use it in GitHub Desktop.
Save chewmanfoo/4485800 to your computer and use it in GitHub Desktop.
def replace_line_in_file(old,new,file)
@file = File.open(file)
@fst = @file.read
@file.close
@fst.gsub!(old,new)
File.open(file,"w") {|f| f.puts @fst}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment