From: Fosiul Alam Date: 2012-08-13T16:58:09+09:00 Subject: Re: Delete a lines from a files Jan E. wrote in post #1072105: > Guys, you really need to stop wanking off over your great Ruby skills > and maybe post a solution that an average user can actually understand > and integrate in his code. LOl thanks , those one liner was bit hard for me to understand .. > > We all know you are the greatest Ruby hackers on earth with the fanciest > one-liners ever. But I think we're here to help and not to masturbate > all day long. > > What about a simple solution? > > old_file = 'test.txt' > new_file = 'test2.txt' > File.open new_file, 'w' do |file| > # loop over the lines of old_file and write those > # not beginning with "john" to new_file > File.foreach old_file do |line| > file << line unless line.start_with? 'john' > end > end this code will work perfect .. thanks -- Posted via http://www.ruby-forum.com/.