antichef has asked for the wisdom of the Perl Monks concerning the following question:
tail: bigfile.log: Invalid argument Assertion failed: valid_file_spec (f), file tail.c, line 700
So I stepped in and slogged out some Perl to get the last 1000 lines of the file:
It works (it takes forever), but there's got to be a better way... :) I looked through the docs haven't had much luck. Any suggestions?open (FILE,"<bigfile.log"); while ($line = <FILE>) { $count++; } $numlines = $count; $count = 0; close FILE; open (FILE,"<bigfile.log"); open (SMALLERFILE,">smallerfile.log"); while ($line = <FILE>) { $count++; if ($count > $numlines - 1000) { print SMALLERFILE $line; } } close FILE; close SMALLERFILE;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: breaking up very large text files - windows
by dga (Hermit) on Jul 28, 2003 at 20:32 UTC | |
Re: breaking up very large text files - windows
by fglock (Vicar) on Jul 28, 2003 at 20:44 UTC | |
Re: breaking up very large text files - windows
by CountZero (Bishop) on Jul 28, 2003 at 20:55 UTC | |
Re: breaking up very large text files - windows
by skyknight (Hermit) on Jul 28, 2003 at 21:36 UTC | |
Re: breaking up very large text files - windows
by Cody Pendant (Prior) on Jul 28, 2003 at 23:41 UTC | |
by CountZero (Bishop) on Jul 29, 2003 at 06:33 UTC | |
Re: breaking up very large text files - windows
by derby (Abbot) on Jul 28, 2003 at 20:31 UTC |