Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created January 8, 2013 17:23
Show Gist options
  • Select an option

  • Save chewmanfoo/4485800 to your computer and use it in GitHub Desktop.

Select an option

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