From: Eero Saynatkari Date: 2005-12-19T07:03:37+09:00 Subject: Re: Removing parts from a file Thomas Dutch wrote: > Hello, > > I'm relatively new to Ruby and I have a question: > > Is it possible to remove one or more lines from a file, without reading > the whole file and writing it away again? This because I'll have to do > this with files of 1 gigabyte and larger... Is there a high performance > solution for this? You could read the files in small blocks or line per line and only process that small part at once. I must say I am not quite sure if ruby internally buffers the file (though I assume not), so maybe try: File.open(fromfile, 'r') {|from| File.open(tofile, 'w') {|to| if (line = from.gets) == some_condition to.puts line end } } > Thank you! E -- Posted via http://www.ruby-forum.com/.