From: Xan Xann Date: 2006-09-07T23:29:04+09:00 Subject: Re: word substitution in file Jason Nordwick wrote: > def substitute(f,g,w,x) `sed s/#{w}/#{x}/g < #{f} > #{g}` end Thank you but I get this errors: sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `sed s/ol/ur/g < # > #' What happens? The code: " f1 = File.open("original.txt") f2 = File.open("canviada.txt") def substitute(f,g,w,x) `sed s/#{w}/#{x}/g < #{f} > #{g}` end substitute(f1,f2,"ol","ur") " original file has " Hello folks or old men " and canviada is empty Thanks in advance, Xan. -- Posted via http://www.ruby-forum.com/.