home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!saimiri.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!reed!romulus!merlyn
- From: merlyn@ora.com (Randal L. Schwartz)
- Newsgroups: comp.unix.questions
- Subject: Re: How to chop up an archive.tar.Z file like in the X distributions?
- Message-ID: <MERLYN.92Dec16113051@romulus.reed.edu>
- Date: 16 Dec 92 19:30:55 GMT
- Article-I.D.: romulus.MERLYN.92Dec16113051
- References: <1992Dec15.142232.1@cc.utah.edu>
- Sender: news@reed.edu (USENET News System)
- Organization: Stonehenge Consulting Services; Portland, Oregon, USA
- Lines: 36
- In-Reply-To: eyring@cc.utah.edu's message of 15 Dec 92 20:22:32 GMT
-
- In article <1992Dec15.142232.1@cc.utah.edu> eyring@cc.utah.edu writes:
- How to chop up an archive.tar.Z file like in the X distributions?
-
- I use my "binsplit" program, like so:
-
- #!/usr/bin/perl
-
- $size = 65536;
- $size = shift if $ARGV[0] =~ /^-\d+$/;
-
- for (@ARGV) {
- $part = 0;
- (warn "Cannot open $_: $!"), next
- unless open(STDIN, $_);
- # create output filename
- s#.*/##;
- tr#a-zA-Z0-9\-.##cd;
- $_ = "binsplit" unless length;
- $outname = $_;
- while (read(STDIN,$_,$size)) {
- open(STDOUT,sprintf(">$outname.p%03d", ++$part)) ||
- die "Cannot create $outname.pNNN: $!";
- print;
- }
- close(STDOUT); # force final flush
- }
-
-
- give it args of "-32768 archive.tar.Z" to turn archive.tar.Z into
- archive.tar.Z.p001 through archive.tar.Z.p999 in 32k chunks.
-
- Just another Perl hacker,
- --
- Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
- merlyn@ora.com (semi-permanent) merlyn@reed.edu (for newsreading only)
- factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"
-