Article View: comp.sys.ibm.pc.misc
Article #9376Re: SPLIT
From: Raymond Chen
Date: Sat, 20 Apr 1991 17:43
Date: Sat, 20 Apr 1991 17:43
39 lines
2255 bytes
2255 bytes
In article <6256@optilink.UUCP>, cramer@optilink (Clayton Cramer) writes:
>In article <1991Apr15.024343.6027@cs.mcgill.ca>, storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes:
>>
>>I am looking for any program that will split up large files into smaller ones
>
>Couldn't find a valid path to you, and this may be generally useful:
>[long program deleted]
Gack, a 101-line program to do something as simple as chopping a file?
Get perl from SIMTEL20:<MSDOS.PERL> and run the following script;
notice that the instructions are longer than the program!
If you have 4DOS, you can type `set .pl=c:\bin\perl.exe' and call
this script `split.pl', then you can just type `split 64 bigfile file0000'.
# split: Chop a file into bite-sized pieces.
#
# Usage: split # file result
#
# Chops the <file> into pieces <#>K in size.
#
# <result> provides the file names to use. If it ends in digits, then
# the digits are incremented. For example if you say `file0001' then
# the output files will be `file0001' `file0002' `file0003'...
#
# If <result> ends in letters, then the letters are incremented. For
# example, if you say `fileaa', then the output files will be `fileaa',
# `fileab', ... `fileaz', `fileba' ...
#
die "usage: split # file result\n" unless (($s $f, $r) = @ARGV) == 3;
open(f) || die "Couldn't open $f ($!)"; binmode(f);
while (read(f, $_, $s * 1024)) {
die "Will not overwrite existing file $r\n" if -e $r;
open(R, ">$r") || die "Couldn't open $r for writing ($!)"; binmode(R);
print R || die "Error writing $r ($!)";
close(R) || die "Error closing $r ($!)";
++$r;
}
Technical Details
Message-ID:
<1991Apr20.174349.20119@agate.berkeley.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!rutgers!att!ucbvax!agate!sunkist.berkeley.edu!raymondReferences:
<1991Apr15.024343.6027@cs.mcgill.ca> <6256@optilink.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!rutgers!att!ucbvax!agate!sunkist.berkeley.edu!raymond From: raymond@math.berkeley.edu (Raymond Chen) Newsgroups: comp.sys.ibm.pc.misc Subject: Re: SPLIT Message-ID: <1991Apr20.174349.20119@agate.berkeley.edu> Date: 20 Apr 91 17:43:49 GMT References: <1991Apr15.024343.6027@cs.mcgill.ca> <6256@optilink.UUCP> Sender: root@agate.berkeley.edu (Charlie Root) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Organization: U.C. Berkeley Lines: 39 In-Reply-To: cramer@optilink.UUCP (Clayton Cramer) Originator: raymond@sunkist.berkeley.edu