summaryrefslogtreecommitdiff
path: root/parasort.sh
blob: b593bb9647f9dbb06dbdf6bdca08a501ef38d2e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

trap ctrl_c INT

function ctrl_c() {
    kill $(jobs -p)
    echo "Killed."
}

if ! test -d work; then
  printf "This directory contains no work/ directory.\n"
  [ -d ../work ] && printf "(but .. does)\n"
  exit 1
fi

export PATH=${PATH}:`pwd -P`/bin/

mkdir -p work/sorted
cd work/output || exit 1

starttime=`date +%s`

for a in ???[05]?;     do echo "$a" >&2; merge_entries $a > ../sorted/$a; done &
for a in ???[16]?;     do echo "      $a" >&2; merge_entries $a > ../sorted/$a; done &
for a in ???[27]?;     do echo "            $a" >&2; merge_entries $a > ../sorted/$a; done &
for a in ???[38]?;     do echo "                  $a" >&2; merge_entries $a > ../sorted/$a; done &
for a in ???[49]?;     do echo "                        $a" >&2; merge_entries $a > ../sorted/$a; done &
for a in brken ???_?;  do echo "                              $a" >&2; merge_entries $a > ../sorted/$a; done &

wait

elapsed=$(( `date +%s` - starttime ))
printf "Finished in %d seconds (%d minutes)\n" ${elapsed} $(( elapsed / 60 ))