Jason Nordwick
9/6/2006 10:46:00 PM
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
>