Remove first line from any readable file

Thursday, October 29, 2009

Code to use in ruby


filename = "/path-to/file/file.ext"
text=''
File.open(filename,"r"){ |f| f.gets; text=f.read}
File.open(filename,"w+"){ |f| f.write(text)}


Make sure that variable "filename" should be in lowercase
If you want a variable in uppercase then you have to declare it outside the def/method.

Leave a Reply

Powered by Blogger.