randomfox: (Default)
[personal profile] randomfox
Perl script that splits a file into 100 million-byte pieces. It system()s out to the dd utility, so it could be rewritten in pure Perl.

Usage example: split.pl largefile lf
will produce lf0, lf1, lf2, lf3... until there are no more pieces.

#!perl -w
use strict;

@ARGV >= 2 or die "Usage: $0 file prefix\n";

my $fname = shift;
my $prefix = shift;

my $fsize;
defined($fsize = -s $fname) or die "Error stating file $fname: $!\n";

my $splitcount = int($fsize / 1e8);

for my $i (0 .. $splitcount) {
    print "Split $i of $splitcount...\n";
    system "dd if=$fname of=$prefix$i bs=100MD count=1 skip=$i";
}

__END__

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 1st, 2025 03:26 pm
Powered by Dreamwidth Studios