/
clean.sh
51 lines (46 loc) · 1.03 KB
/
clean.sh
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
48
49
50
51
#!/bin/bash
#
# Script for cleaning up experiment directories.
#
# After this script is run, the experiment directory is returned to
# its state before replicate.py was run, i.e., with only a yaml file
# for configuration.
#
# Usage:
#
# bash clean.sh experiments/<experiment_directory>
#
# or, to clean all experiments directories:
#
# bash clean.sh experiments/*
#
#
# Bobak Shahriari
# 25 September 2014
#
for EXPT in $@; do
# delete experiment subdirectories
EXPT_PATH=$(pwd)/$EXPT
LIST_PATH=`find $EXPT_PATH/* -type d`
# check for empty string (null string)
if [[ -n "$LIST_PATH" ]]; then
rm -rf `ls -d $EXPT_PATH/*/`
fi
# delete execute.py script if it exists
EXE_PY=$EXPT_PATH/execute.py
EXE_PBS=$EXPT_PATH/execute.pbs
if [[ -e "$EXE_PY" ]]; then
rm $EXE_PY
fi
if [[ -e "${EXE_PY}c" ]]; then
rm ${EXE_PY}c
fi
if [[ -e "$EXE_PBS" ]]; then
rm $EXE_PBS
fi
done
# unset environment variables
unset EXPT_PATH
unset LIST_PATH
unset EXE_PY
unset EXE_PBS