-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpcf
More file actions
57 lines (48 loc) · 1.23 KB
/
pcf
File metadata and controls
57 lines (48 loc) · 1.23 KB
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
52
53
54
55
56
57
#!/bin/bash -x
found=`ls -t1 *.py | head -n 1`
if [ -f $found ]; then
echo 'target: $found'
else
echo 'bad target, must exit...'
exit
fi
fileNoExt=${found::-3}
fileWithExt=$fileNoExt'.py'
moveTarget="${HOME}/uva/src/python/py-accepted"
tmp='tmp'
for i in {1..10}; do x=$RANDOM; tmp="${tmp}$(((x%10)+1))"; done
if [ -f $fileWithExt ]; then
cp -n $fileWithExt $tmp
if [ -d $moveTarget ]; then
echo 'moving $fileWithExt to $moveTarget'
mv $fileWithExt $moveTarget/$fileWithExt
if [ -f $moveTarget/$fileWithExt ]; then
echo 'file has been moved successfully'
echo 'deleting temporary file: $tmp'
rm $tmp
else
echo 'error has occurred, file not moved to $moveTarget successfully'
echo 'backup exists as ${tmp}, please investigate and try again'
exit
fi
fi
fi
if [ -f $fileNoExt".exe" ]; then
rm $fileNoExt".exe"
fi
echo '-------'
echo 'performing cleanup'
toremove=(o t sol)
for j in ${toremove[@]}
do
if [ -f ${j} ]; then
echo removing ${j}...
rm ${j}
fi
done
find -maxdepth 1 -type f -name '*~' -delete
find -maxdepth 1 -type f -name '*.in' -delete
find -maxdepth 1 -type f -name '*.out' -delete
find -maxdepth 1 -type f -name '*.ans' -delete
echo 'done cleanup...'
echo 'Success!'