From: Jason Nordwick Date: 2006-09-07T07:45:48+09:00 Subject: Re: word substitution in file def substitute(f,g,w,x) `sed s/#{w}/#{x}/g < #{f} > #{g}` end Xan Xann wrote: > Hi, > > Can anyone help me in that? > I just want to write the following function: > > substitute(f,g,w,x) > > where f and g are files and w and x are strings > That function substitutes all the ocurrences of w in the file f and > writes x to g > > For example, if f is: > " > Hello folks or > old men > " > > and w = "ol" and x="ur" > > then g is: > > " > Hello furks or > urd men > " > > Can anyone show me some code? > I thinked to pass file to string but I thinked it was not very fast. > Better directly >