Careful of the rm -f ${FILE} at the end … I’ve commented it out at first, but if you want to save space, it’ll remove the file you’re splitting from.
#!/bin/bash
FILE="$1"
set -x
#How big we want the chunks to be in bytes
CHUNKSIZE=$(( 23 * 1024 * 1024 * 1024 ))
echo "${CHUNKSIZE} - Blu Ray"
#Block size for dd in bytes
BS=$(( 8 * 1024 ))
#Convert CHUNKSIZE to blocks
CHUNKSIZE=$(( $CHUNKSIZE / $BS ))
# Skip value for dd, we start at 0
SKIP=0
#Calculate total size of file in blocks
FSIZE=`stat -F ${FILE} | awk '{print $5}'`
SIZE=$(( $FSIZE / $BS ))
#Loop counter for file name
i=0
echo "Using chunks of "$CHUNKSIZE" blocks"
echo "Size is "$FSIZE" bytes = "$SIZE" blocks"
while [ $SKIP -le $SIZE ]; do
NEWFILE="$FILE".part"$i"
i=$(( $i + 1 ))
echo "Creating file "$NEWFILE" starting after block "$SKIP""
dd if="$FILE" of="$NEWFILE" bs="$BS" count="$CHUNKSIZE" skip=$SKIP
SKIP=$(( $SKIP + $CHUNKSIZE ))
done
#rm -f ${FILE}