Révision 17
submit/clean_up.sh (revision 17) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 |
# $Id$ |
|
2 | 3 |
#How to use this script: |
3 | 4 |
#The usage is similar to the command rsync, |
4 | 5 |
#clean_up files_to_be_synced destination |
5 |
set -euo pipefail # strict mode |
|
6 |
set -x # Trace each command, can be commented |
|
6 |
set -eu # partial strict mode |
|
7 |
set -o pipefail # exit, with error msg from any forked subshell, if exit code != 0 |
|
8 |
set -x # Trace each command, can be commented out |
|
7 | 9 |
|
8 | 10 |
#number of files to be synced |
9 | 11 |
narg=$(($#-1)) |
... | ... | |
13 | 15 |
|
14 | 16 |
pwd=$(pwd) |
15 | 17 |
#echo "${files}" |
18 |
# TODO: enter a loop, and sync one file at a time (Tao said) |
|
16 | 19 |
rsync -r -c $@ |
17 | 20 |
|
21 |
|
|
18 | 22 |
#If exit code is 0 (succeed), then delete the files |
19 | 23 |
if [[ $? -ne 0 ]] |
20 | 24 |
then |
... | ... | |
22 | 26 |
echo "The directory is: ${pwd}" |
23 | 27 |
exit 1 |
24 | 28 |
else |
29 |
echo "deleting ${files}" |
|
25 | 30 |
rm $files |
26 |
echo "deleting ${files}" |
|
27 | 31 |
echo "Done" |
28 | 32 |
fi |
29 | 33 |
Formats disponibles : Unified diff