#!/usr/bin/perl -w use strict; use constant BLOCKSIZE => 128 * 1024; my $USAGE =<= 0; my $completed = 0; for my $file (@ARGV) { open(my $fh, "+<", $file) or warn("Couldn't open $file: $!\n"),next; if(-s $fh > $nbytes ) { seek $fh, $nbytes, 0; my $total_in = 0; while(my $bytes_in = read $fh, my $buf, BLOCKSIZE) { my $eof = eof($fh); seek $fh, $total_in, 0; print $fh $buf; $total_in += $bytes_in; last if $eof; seek $fh, $nbytes + $total_in, 0; } } truncate $fh, tell $fh; close $fh; $completed++; } exit ($completed == 0);