Subject: Re: Couple Questions...
To: Chris Larson <larson@cs.utk.edu>
From: Ken Nakata <kenn@eden.rutgers.edu>
List: port-mac68k
Date: 03/23/1996 22:03:22
> :> Hi, im trying to figure out how to segment an 8.5 meg file into smaller
> :> segments, ftp them, then reassemble them in NetBSD. ANy help is
> :> appreciated... my provider hangs up on my for some reason after about an
> :> hour connected so i cant finish the FTP...
> 
> Try "split".
> You can then cat * >> original.file

While you can safely "split" a binary file on BSD systems, some
systems (even BSD-derived Ultrix) don't have split with "-b" option.

It's safer to "uuencode" the file first then "split", just like
Steve wrote.

However, this mail would be pointless unless I added something to this
thread...  ;-) so here it goes my favorite binary split shell script:

#!/bin/sh
# usage: bsplit <file> <chunk_size>
#
case "$2" in
*k|*K) chunksize=`echo $2 | sed 's/^\([0-9]*\)[kK]/\1/'`
    chunksize=`expr $chunksize \* 1024`; ;;
*m|*M) chunksize=`echo $2 | sed 's/^\([0-9]*\)[mM]/\1/'`
    chunksize=`expr $chunksize \* 1024 \* 1024`; ;;
*) chunksize=$2; ;;
esac
# echo chunk size is $chunksize
#
filesize=`ls -l $1 | awk '{ print $5 }'`
# echo file size is $filesize
chunks=`expr \( $filesize + $chunksize - 1 \) / $chunksize`
# echo '#' of chunks is $chunks
#
i=0
while [ $i -lt $chunks ]; do
  dd if=$1 of=$1.`echo $i | sed -e 's/^/0000/' -e 's/^.*\(....\)$/\1/'` bs=$2 skip=$i count=1
  i=`expr $i + 1`
done

As always, it could use some more error checking, but it served me
well when my main host on the net was an Ultrix machine.  And of
course I tried to use only "standard" UNIX commands.

ken