From: Thomas Pierce Date: 2008-02-18T13:00:29+09:00 Subject: Help with Writing Replacement Text to Files Hello! I'm new to ruby and been reading this very active list for about a couple of week. I have a project at work where I need to write a simple script to scrub IP addresses from configuration files for classified networks we work in sometimes. The goal is to cleanse configuration files sometimes required for support of any specific network addressing information. Here is what I've come up with so far. While this works in IRB on the file object I create, I cannot figure out how to write the changes back in place to the actual file itself back on the regex I'm using: config_file = File.open("config.txt") config_txt = config_file.read config_txt.gsub!(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/, "000.000.000.000") I do understand that the default action here is read-only. How to do I parse with the regex on the current file and replace matching strings without either appending to the file, overwriting the file, or creating a new file? Thanks! ~Thomas