chimie4psmn / submit / clean_up.sh @ 16
Historique | Voir | Annoter | Télécharger (583 octet)
1 |
#!/bin/bash |
---|---|
2 |
#How to use this script: |
3 |
#The usage is similar to the command rsync, |
4 |
#clean_up files_to_be_synced destination |
5 |
set -euo pipefail # strict mode |
6 |
set -x # Trace each command, can be commented |
7 |
|
8 |
#number of files to be synced |
9 |
narg=$(($#-1)) |
10 |
|
11 |
#files to be synced |
12 |
files=${@:1:$narg} |
13 |
|
14 |
pwd=$(pwd) |
15 |
#echo "${files}" |
16 |
rsync -r -c $@ |
17 |
|
18 |
#If exit code is 0 (succeed), then delete the files |
19 |
if [[ $? -ne 0 ]] |
20 |
then |
21 |
echo "Failed copying back all the data. Please verify manually." |
22 |
echo "The directory is: ${pwd}" |
23 |
exit 1 |
24 |
else |
25 |
rm $files |
26 |
echo "deleting ${files}" |
27 |
echo "Done" |
28 |
fi |