Read file from bottom

Hardy Merrill hmerrill at redhat.com
Mon May 13 17:20:34 EDT 2002


You probably already know this, but on the chance you don't,
you can add a parameter to tail to tell it how many lines from
the bottom you want.  For example, if I want 35 lines from the
bottom I can do

   tail -35 <filename> | python script.py

HTH.

-- 
Hardy Merrill
Senior Software Engineer
Red Hat, Inc.

Julia Bell [julia.bell at jpl.nasa.gov] wrote:
> Good idea; I never thought of something like that.
> 
> My initial reaction is that I don't know I exactly how many lines frm the
> bottom I want.  (I currently read the lines, search for data on the lines
> that meets some trigger criterion, and then start processing the data from
> there.)  But, there still might be something worth thinking about regarding
> whether it is more efficient to pre-process the data (similar to using
> 'tail') than to process it as part of my script.
> 
> Thanks.
> 
> Julia Bell
> 
> 
> William Park wrote:
> 
> > Julia Bell <julia.bell at jpl.nasa.gov> wrote:
> >
> > >
> > > Is there an efficient (and relatively easy - I'm new to Python) way of
> > > reading the file from the last line backward instead of the first line
> > > forward?
> >
> >
> > tail | python script.py
> >
> > --
> > William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
> > 8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list