#!/bin/bash SHOWLINES=2 if [ -z "$1" ]; then echo "" echo "Usage: $0 [file] [number of chunks to split file into]" echo "" exit 1 else SRCFILE=$1 COUNT=$2 let "COUNT+=0" fi if [ ! -f "${SRCFILE}" ]; then echo "" echo "- Error: first param should be a file that exists" echo "" exit 2 fi if [ -f ${SRCFILE}.aa ]; then echo "" echo "- Warning: file ${SRCFILE}.aa already exists" ls -la ${SRCFILE}.aa echo "" exit 3 fi echo "- Original file:" ls -lah ${SRCFILE} echo "" echo "- Splitting, please wait." time split --verbose -n l/${COUNT} ${SRCFILE} ${SRCFILE}. echo "" echo "- Split complete. Results:" for file in ${SRCFILE}.??; do touch -r ${SRCFILE} $file ls -lah $file echo "- First ${SHOWLINES} of $file:" head -n ${SHOWLINES} $file echo "- Last ${SHOWLINES} of $file:" tail -n ${SHOWLINES} $file echo "" done