From: Rob Biedenharn Date: 2008-06-05T10:42:29+09:00 Subject: Re: deleting first line from a file If that's all you want (and you're not frightened by the command-line options): ruby -i -n -e 'puts $_ if $. > 1' lines.txt Of if you want to keep the original in lines.txt.orig ruby -i.orig -n -e 'puts $_ if $. > 1' lines.txt -Rob On Jun 4, 2008, at 9:16 PM, Peņa, Botp wrote: > From: suresh [mailto:suresh.amritapuri@gmail.com] > # I have a HUGE data file multiple lines of data. I want to delete > just > # the first line from it. How to do it efficiently? > > i think you want something fast yet clean ruby solution. > > maybe something like, > > botp@botp-desktop:~$ cat test.txt > this line will be deleted > 2nd line > 3rd asdfasdf line > 4th qwerty line > 5th > 6th six > 7th 777777777777 > > botp@botp-desktop:~$ irb > irb(main):001:0> File.open("newfile","w") do |fw| > irb(main):002:1* File.open("test.txt") do |fr| > irb(main):003:2* fr.gets > irb(main):004:2> fw.write fr.read > irb(main):005:2> end > irb(main):006:1> end > => 72 > > botp@botp-desktop:~$ cat newfile > 2nd line > 3rd asdfasdf line > 4th qwerty line > 5th > 6th six > 7th 777777777777 > > > just add some checks/rescues so that it will work on all your cases. > > kind regards -botp > Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com