Blame view

egs/wsj/s5/steps/nnet2/remove_egs.sh 1.27 KB
8dcb6dfcb   Yannick Estève   first commit
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
  #!/bin/bash
  
  # Copyright 2014  Johns Hopkins University (Author: Daniel Povey).  
  # Apache 2.0.
  
  # This script removes the examples in an egs/ directory, e.g.
  # steps/nnet2/remove_egs.sh exp/nnet4b/egs/
  # We give it its own script because we need to be careful about
  # things that are soft links to something in storage/ (i.e. remove the
  # data that's linked to as well as the soft link), and we want to not
  # delete the examples if someone has done "touch $dir/egs/.nodelete".
  
  
  if [ $# != 1 ]; then
    echo "Usage: $0 <egs-dir>"
    echo "e.g.: $0 data/nnet4b/egs/"
    echo "e.g.: $0 data/nnet4b_mpe/degs/"
    echo "This script is usually equivalent to 'rm <egs-dir>/egs.* <egs-dir>/degs.*' but it follows"
    echo "soft links to <egs-dir>/storage/; and it avoids deleting anything in the directory if"
    echo "someone did 'touch <egs-dir>/.nodelete"
    exit 1;
  fi
  
  egs=$1
  
  if [ ! -d $egs ]; then
    echo "$0: expected directory $egs to exist"
    exit 1;
  fi
  
  if [ -f $egs/.nodelete ]; then
    echo "$0: not deleting egs in $egs since $egs/.nodelete exists"
    exit 0;
  fi
  
  
  
  for f in $egs/egs.*.ark $egs/degs.*.ark $egs/cegs.*.ark; do
    if [ -L $f ]; then
      rm $(dirname $f)/$(readlink $f)  # this will print a warning if it fails.
    fi
    rm $f 2>/dev/null
  done
  
  
  echo "$0: Finished deleting examples in $egs"