From: "Ara.T.Howard" Date: 2004-05-20T21:23:48+09:00 Subject: Re: seraching backward in files On Thu, 20 May 2004, Patrick Gundlach wrote: > Dear ruby hackers, > > I'd wonder if there is a simple method in searching backward in > files. I want to read a pdf file, so I have to do the following: > > 1) goto the end of file (pdffile.seek(0,IO::SEEK_END)) > 2) search backward for the string "%%EOF" within the last 1024 bytes > 3) search backward for "startxref" > 4) read the next bytes,..... > > > Do I have to write my own seach backward routine or is there some > functionality for it? > > Best regards, > > Patrick > if you are on linux you might want to simply tac = IO.popen "tac #{ path }" # process file in 'normal' fashion - only backwards... man 1 tac cheers. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | "640K ought to be enough for anybody." - Bill Gates, 1981 ===============================================================================