Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: breaking up very large text files - windows

by dga (Hermit)
on Jul 28, 2003 at 20:32 UTC ( [id://278606]=note: print w/replies, xml ) Need Help??


in reply to breaking up very large text files - windows

One possibility is to seek to the end of the file and work back from there.

If you don't need exactly 1000 lines another possibility is to seek to some distance from the end say 1k bytes, read and ignore one line (probably part of a line) then output the rest of the file to your smallfile. Of course if the log messages are a fixed length then the math to get 1000 lines from the end is easy to do. Though since you want to tail the files then some number of kilobytes then reading forward to the next linebreak to get the start of a line should probably work and quickly to boot.

open(BIG, "name_here"); open(SMALL, "other_name_here"); seek(BIG, -1024, 2); my $junk=<BIG>; #pitch to end of current line while(<BIG>) { print SMALL $_; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found