| 1 | #!/bin/bash |
| 2 | # splitcopy.sh |
| 3 | |
| 4 | # A script that splits itself into chunks, |
| 5 | #+ then reassembles the chunks into an exact copy |
| 6 | #+ of the original script. |
| 7 | |
| 8 | CHUNKSIZE=4 # Size of first chunk of split files. |
| 9 | OUTPREFIX=xx # csplit prefixes, by default, |
| 10 | #+ files with "xx" ... |
| 11 | |
| 12 | csplit "$0" "$CHUNKSIZE" |
| 13 | |
| 14 | # Some comment lines for padding . . . |
| 15 | # Line 15 |
| 16 | # Line 16 |
| 17 | # Line 17 |
| 18 | # Line 18 |
| 19 | # Line 19 |
| 20 | # Line 20 |
| 21 | |
| 22 | cat "$OUTPREFIX"* > "$0.copy" # Concatenate the chunks. |
| 23 | rm "$OUTPREFIX"* # Get rid of the chunks. |
| 24 | |
| 25 | exit $? |