From: Robert Klemme Date: 2007-04-04T01:10:05+09:00 Subject: Re: search a file and replace text On 03.04.2007 17:47, phil.swenson@gmail.com wrote: > I need to search a specific xml file in a directory, look for: > > 30890 > > and if the port 30890 is still there replace it with a different > integer. > > I know of several ways to do this (like open the file, iterate the > lines until I find the integer, do a gsub! on on the integer). But it > seems like there might be a better way to do it. Is there a search > and replace API I don't know about? Look for ruby -pi.bak -e 'gsub ...' robert