home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14749 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.6 KB

  1. 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
  2. From: merlyn@ora.com (Randal L. Schwartz)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: How to chop up an archive.tar.Z file like in the X distributions?
  5. Message-ID: <MERLYN.92Dec16113051@romulus.reed.edu>
  6. Date: 16 Dec 92 19:30:55 GMT
  7. Article-I.D.: romulus.MERLYN.92Dec16113051
  8. References: <1992Dec15.142232.1@cc.utah.edu>
  9. Sender: news@reed.edu (USENET News System)
  10. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  11. Lines: 36
  12. In-Reply-To: eyring@cc.utah.edu's message of 15 Dec 92 20:22:32 GMT
  13.  
  14. In article <1992Dec15.142232.1@cc.utah.edu> eyring@cc.utah.edu writes:
  15.    How to chop up an archive.tar.Z file like in the X distributions?
  16.  
  17. I use my "binsplit" program, like so:
  18.  
  19. #!/usr/bin/perl
  20.  
  21. $size = 65536;
  22. $size = shift if $ARGV[0] =~ /^-\d+$/;
  23.  
  24. for (@ARGV) {
  25.     $part = 0;
  26.     (warn "Cannot open $_: $!"), next
  27.         unless open(STDIN, $_);
  28.     # create output filename
  29.     s#.*/##;
  30.     tr#a-zA-Z0-9\-.##cd;
  31.     $_ = "binsplit" unless length;
  32.     $outname = $_;
  33.     while (read(STDIN,$_,$size)) {
  34.         open(STDOUT,sprintf(">$outname.p%03d", ++$part)) ||
  35.             die "Cannot create $outname.pNNN: $!";
  36.         print;
  37.     }
  38.     close(STDOUT); # force final flush
  39. }
  40.  
  41.  
  42. give it args of "-32768 archive.tar.Z" to turn archive.tar.Z into
  43. archive.tar.Z.p001 through archive.tar.Z.p999 in 32k chunks.
  44.  
  45. Just another Perl hacker,
  46. --
  47. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  48. merlyn@ora.com (semi-permanent) merlyn@reed.edu (for newsreading only)
  49. factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"
  50.