home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!murphy!jpradley!jpr
- From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
- Subject: Re: How to chop up an archive.tar.Z file like in the X distributions?
- Date: Thu, 24 Dec 1992 02:16:21 GMT
- Message-ID: <1992Dec24.021621.8958@jpradley.jpr.com>
- References: <1992Dec15.142232.1@cc.utah.edu> <1992Dec19.053319.12598@jpradley.jpr.com>
- Organization: Unix in NYC
- Lines: 58
-
- In article <1992Dec19.053319.12598@jpradley.jpr.com> jpr@jpradley.jpr.com (Jean-Pierre Radley) writes:
- >In article <1992Dec15.142232.1@cc.utah.edu> eyring@cc.utah.edu writes:
- >>
- >>Could someone tell me what unix utility was used to chop up
- >>the big archive.tar.Z files into the smaller but all the same
- >>size files?
- >
- >When I'm faced with this task, I run "chunk":
- >
- >: chunk - breakup a file into SIZE chunks called PREFIX01, PREFIX02, ...
- ># @(#) JPRadley 10 Jan 91
- >[ ! -r "$1" ] && echo "Usage: $0 file [prefix [size]]" && exit
- >IN=$1
- >PREFIX=${2:-chunk}
- >SIZE=${3:-100000}
- >N=0
- >while :
- >do
- > T=`expr $N + 1`
- > [ $T -le 9 ] && T=0$T
- > dd count=1 bs=$SIZE if=$IN skip=$N of=$PREFIX$T
- > [ ! -s $PREFIX$T ] && rm $PREFIX$T && break
- > N=`expr $N + 1`
- >done
- >l $PREFIX* $IN
-
-
- That was last week. Now I'd use "mkparts":
-
-
- :
- # @(#) mkparts - chop a file into ~SIZE parts called PREFIX01, PREFIX02, ...
- # Each part, save the last, will be one byte larger than the one before it,
- # so that "by their size shall you know them".
- # @(#) JPRadley & RCStockler 22 Dec 92 - v1.0
- # N.B.: If your 'dd' doesn't understand 'iseek', use 'skip' instead.
-
- [ ! -r "$1" ] && echo "Usage: $0 file [prefix [size]]" && exit
-
- trap 'rm -f $TFILE.* ; trap 0 ; exit' 0 1 2 3 15
- IF=$1 PREFIX=${2:-part} SIZE=${3:-100000} PART=0 TFILE=/usr/tmp/mkp$$
- rm -f $PREFIX*
-
- while [ -s $IF ]
- do
- eval `awk '
- END { printf( "SIZE=%d OLD=%02d PART=%02d", ++SIZE, PART, ++PART )
- }' SIZE=$SIZE PART=$PART /dev/null`
- dd count=1 bs=$SIZE if=$IF of=$PREFIX$PART 2>/dev/null
- dd iseek=1 bs=$SIZE if=$IF of=$TFILE.$PART 2>/dev/null
- IF=$TFILE.$PART
- rm -f $TFILE.$OLD
- done
-
- l $PREFIX* $1
-
- --
- Jean-Pierre Radley Unix in NYC jpr@jpr.com jpradley!jpr CIS: 72160.1341
-