Simple and inneficient (reads the whole file into memory) Python script:

#!/usr/bin/env python
import sys
split_string = "yousplitstring"
print sys.stdin.read().split(split_string).pop()



On Tue, Jun 15, 2010 at 7:00 PM, Chris Knadle <[email protected]> wrote:
> On Tuesday 15 June 2010 17:37:07 Adam wrote:
>> This is one of those things where I know there must be several dozen
>> ways to do it, but I can't seem to think of any of them!  What I'd like
>> to do is to get all the text from text file "file" starting with the
>> line containing the LAST occurrence of "string", through the last line
>> of "file", and all this will be piped to another program.  Anybody have
>> any ideas?  Thanks!
>>
>> Adam
>
> If you're searching for a single line, one option would be to reverse-
> concatenate the file with 'tac' and then search for the /first/ instance of
> the string.
>
>  -- Chris
>
> --
>
> Chris Knadle
> [email protected]
> _______________________________________________
> Mid-Hudson Valley Linux Users Group                  http://mhvlug.org
> http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug
>
> Upcoming Meetings (6pm - 8pm)                         MHVLS Auditorium
>  Jul 7 - Patent Absurdity - The Movie
>  Aug 4 - Samba
>  Sep 1 - BOINC
>



-- 
 - Max Shkurygin

Those who would give up essential liberty to purchase a little of
safety deserve neither liberty nor safety.
- Benjamin Franklin
_______________________________________________
Mid-Hudson Valley Linux Users Group                  http://mhvlug.org
http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug

Upcoming Meetings (6pm - 8pm)                         MHVLS Auditorium
  Jul 7 - Patent Absurdity - The Movie
  Aug 4 - Samba
  Sep 1 - BOINC

Reply via email to