summaryrefslogtreecommitdiff
path: root/pm-index
blob: 3255da98b05f2a5641d6cbf6dbb3da4375d36aee (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

if [ "$#" -eq 0 ]
then
  echo "Must supply path for indexed files"
  exit 1
fi

target="$1"
shift

target=${target%/}

if [ "$#" -eq 0 ]
then
  echo "Must supply path for data files"
  exit 1
fi

data="$1"
shift

data=${data%/}

find "$target" -name "*.e2x" -delete
find "$target" -name "*.e2x.gz" -delete

for fl in *.xml.gz
do
  base=${fl%.xml.gz}
  echo "$base.e2x"
  seconds_start=$(date "+%s")
  if [ -s "$data/meshtree.txt" ]
  then
    gunzip -c "$fl" |
    xtract -transform "$data/meshtree.txt" -e2index |
    gzip -1 > "$target/$base.e2x.gz"
  else
    gunzip -c "$fl" |
    xtract -e2index |
    gzip -1 > "$target/$base.e2x.gz"
  fi
  seconds_end=$(date "+%s")
  seconds=$((seconds_end - seconds_start))
  echo "$seconds seconds"
  sleep 1
done