#!/usr/bin/perl my $FILE = $ARGV[0]; my $MAXSIZE=10; exit -1 if ! -f $FILE; $num_lines = 0; open FILE, ">$FILE"; for (;;) { chomp($mytime=`date +%T`); my $line = "$mytime"; $line .= ";" . sprintf "%.2f", rand(10); $line .= ";" . sprintf "%.2f", rand(20); $line .= ";" . sprintf "%.2f", rand(30); $line .= ";" . sprintf "%.2f", rand(40); if($num_lines < $MAXSIZE){ push @array, "$line\n"; $num_lines++; }else{ shift @array; push @array, "$line\n"; } #Get the end position of the file seek(FILE, 0, 2); $endpos = tell(FILE); seek(FILE, 0, 0);#Seek to start print FILE @array; #For the rest of the bytes print " " $curpos = tell(FILE); for(my $cnt=$curpos;$cnt<$endpos;$cnt++){ print FILE " "; } sleep 1; }
In reply to Re: What is the best way to remove(delete) specific lines from a very large file?
by scottysb
in thread What is the best way to remove(delete) specific lines from a very large file?
by Flame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |