Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Reading a file from any arbitrary place in the file.

by davidrw (Prior)
on Nov 21, 2005 at 19:36 UTC ( [id://510540]=note: print w/replies, xml ) Need Help??


in reply to Reading a file from any arbitrary place in the file.

Basic approach is to read through the while file, and set the flag once you hit your marker, and print if the flag is set.
perl -ne 'if($ok){print;}else{$ok=/^This is the temp line\.$/}' foo.tx +t
Another approach, if the file is small enough, is to slurp into memory and split it, using your marker as the delimiter:
perl -n0777e 'print ((split(/^This is the temp line.\n/m, $_, 2))[-1]) +' foo.txt

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://510540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found