LDP/LDP/guide/docbook/abs-guide/splitcopy.sh

26 lines
538 B
Bash

#!/bin/bash
# splitcopy.sh
# A script that splits itself into chunks,
#+ then reassembles the chunks into an exact copy
#+ of the original script.
CHUNKSIZE=4 # Size of first chunk of split files.
OUTPREFIX=xx # csplit prefixes, by default,
#+ files with "xx" ...
csplit "$0" "$CHUNKSIZE"
# Some comment lines for padding . . .
# Line 15
# Line 16
# Line 17
# Line 18
# Line 19
# Line 20
cat "$OUTPREFIX"* > "$0.copy" # Concatenate the chunks.
rm "$OUTPREFIX"* # Get rid of the chunks.
exit $?