7 printf "%s file pieces\n" "$0"
8 printf "splits file into 'pieces' pieces.\n"
13 echo "error: file not exists"
17 fs
=$
(wc -c "$file"| cut
-d " " -f 1)
19 chunksz
=$
((fs
/ pieces
))
21 md5
=$
(md5sum "$file"| cut
-d " " -f 1)
24 script=$
(printf "%s.assemble.sh" "$file")
25 echo "#!/bin/sh" > "$script"
26 echo "rm -f \"$f\"" >> "$script"
27 for i
in `seq $pieces` ; do
28 of
=$
(printf "%s.part.%.4d" "$file" "$i")
30 if [ "$i" = "$pieces" ] ; then bytes
=$
((fs
- ((pieces-1
)*chunksz
) )) ; fi
31 dd if="$file" of
="$of" bs
=1 skip
="$bdone" count
="$bytes" >/dev
/null
2>&1
32 bdone
=$
((bdone
+ bytes
))
34 echo "cat \"$ofs\" >> \"$f\"" >> "$script"
37 cat << EOF >> "$script"
38 test \$(md5sum "$f" | cut -d " " -f 1) = $md5 || {
42 echo "successfully recreated $f"
45 echo "created $script".