home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.wanted
- Path: sparky!uunet!murphy!jpradley!jpr
- From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
- Subject: Re: File splitting program wanted
- Date: Sat, 23 Jan 1993 03:27:05 GMT
- Message-ID: <1993Jan23.032705.20431@jpradley.jpr.com>
- References: <6541@mccuts.uts.mcc.ac.uk>
- Organization: Unix in NYC
- Lines: 34
-
- In article <6541@mccuts.uts.mcc.ac.uk> ehgabp2@uts.mcc.ac.uk (Barry Prescott) writes:
- >I need to split a large binary file into chunks of a certain length.
- >The X distribution tape must have been split by a program such as this,
- >as it can be picked up in 512K chunks from ftp sites.
- >
-
- :
- # @(#) 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
- # EOF 'mkparts'
- --
- Jean-Pierre Radley Unix in NYC jpr@jpr.com jpradley!jpr CIS: 72160.1341
-