[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: file splitter and merger??



On Thu, Nov 29, 2007 at 10:35:32AM +1100, Lux Zhang wrote:
> what are tools to split a large file (etc 700mb a.avi) into small
> pieces and then the merger to merge them?

People have suggested 'split' and 'cat'.  These are at best marginal, at
worst simply won't work for binary files.

Look for a script called 'bsplit'.  If you can't find a distributed version,
something like the attached will work.

Cheers,
--
	Dave Ihnat
	President, DMINET Consulting, Inc.
	dihnat dminet com
#
# bsplit [n] name
#
# Breaks a file into N-block parts, where a block is 512 bytes
#
# Author: Dave Ihnat.  Released as a work in the Public Domain.

BCOUNT=0
FCOUNT=0
BSKIP=0

if [ $# -eq 2 ]
then
	BCOUNT=$1;
	shift;
else
	BCOUNT=100;
fi;

OUTFILE=$1;
PREFIX=00

while [ TRUE ]
do
	echo "$OUTFILE.${PREFIX}${FCOUNT}"

#	dd of=$OUTFILE.${PREFIX}${FCOUNT} skip=$BSKIP count=$BCOUNT
	dd of=$OUTFILE.${PREFIX}${FCOUNT} count=$BCOUNT

	if [ $? -ne 0 ]
	then
		break;
	fi;

	if [ ! -s $OUTFILE.${PREFIX}${FCOUNT} ]
	then
		rm $OUTFILE.${PREFIX}${FCOUNT}
		break;
	fi;

	FCOUNT=`expr $FCOUNT + 1`
	if [ "$FCOUNT" -gt 99 ]
	then
		PREFIX=""
	elif [ "$FCOUNT" -gt 9 ]
	then
		PREFIX="0"
	fi;

	BSKIP=`expr $BSKIP + $BCOUNT`
done

exit 0

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]