home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sources / wanted / 5783 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.5 KB  |  45 lines

  1. Newsgroups: comp.sources.wanted
  2. Path: sparky!uunet!murphy!jpradley!jpr
  3. From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
  4. Subject: Re: File splitting program wanted
  5. Date: Sat, 23 Jan 1993 03:27:05 GMT
  6. Message-ID: <1993Jan23.032705.20431@jpradley.jpr.com>
  7. References: <6541@mccuts.uts.mcc.ac.uk>
  8. Organization: Unix in NYC
  9. Lines: 34
  10.  
  11. In article <6541@mccuts.uts.mcc.ac.uk> ehgabp2@uts.mcc.ac.uk (Barry Prescott) writes:
  12. >I need to split a large binary file into chunks of a certain length.
  13. >The X distribution tape must have been split by a program such as this,
  14. >as it can be picked up in 512K chunks from ftp sites.
  15. >
  16.  
  17. :
  18. # @(#) mkparts - chop a file into ~SIZE parts called PREFIX01, PREFIX02, ...
  19. # Each part, save the last, will be one byte larger than the one before it,
  20. # so that "by their size shall you know them".
  21. # @(#) JPRadley & RCStockler 22 Dec 92 - v1.0
  22. # N.B.: If your 'dd' doesn't understand 'iseek', use 'skip' instead.
  23.  
  24. [ ! -r "$1" ] && echo "Usage: $0 file [prefix [size]]" && exit
  25.  
  26. trap 'rm -f $TFILE.* ; trap 0 ; exit' 0 1 2 3 15
  27. IF=$1 PREFIX=${2:-part} SIZE=${3:-100000} PART=0 TFILE=/usr/tmp/mkp$$
  28. rm -f $PREFIX*
  29.  
  30. while [ -s $IF ]
  31. do
  32.   eval `awk '
  33.         END { printf( "SIZE=%d OLD=%02d PART=%02d", ++SIZE, PART, ++PART )
  34.         }' SIZE=$SIZE PART=$PART /dev/null`
  35.   dd count=1 bs=$SIZE if=$IF of=$PREFIX$PART 2>/dev/null
  36.   dd iseek=1 bs=$SIZE if=$IF of=$TFILE.$PART 2>/dev/null
  37.   IF=$TFILE.$PART
  38.   rm -f $TFILE.$OLD
  39. done
  40.  
  41. l $PREFIX* $1
  42. # EOF 'mkparts'
  43. -- 
  44. Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160.1341
  45.