-
Notifications
You must be signed in to change notification settings - Fork 1
/
clean.sh
executable file
·54 lines (49 loc) · 1.41 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
52
53
#!/bin/bash
green=148
blue=147
function color {
if [ -n "$1" ]; then
echo -e -n "\033[38;5;$1m"
else
echo -e -n "\033[39m"
fi
}
if [[ $1 == h* ]]; then
color $blue
echo "Usage: $0 [OPTION]"
echo " OPTION: <empty> -- mv binary binary.bin"
echo " OPTION: rm -- rm binary"
echo " OPTION: rmbin -- rm binary; rm binary.bin"
echo " OPTION: help -- prints this help"
color
exit
fi
for x in `find . -not -name *.in -not -name *.out -not -name *.aux -not -name *.log`; do
if [[ "$x" == ./.git* ]]; then continue; fi
if [[ "$x" == *.pdf ]] || [[ "$x" == *.tex ]]; then continue; fi
if [[ "$x" == *.in ]] || [[ "$x" == *.out ]]; then continue; fi
if [[ "$x" == *.cpp ]] || [[ "$x" == *.cc ]]; then continue; fi
#echo $x
if file $x | grep -q "ELF"; then
if [[ "$x" == *.bin ]]; then
if [ "$1" == "rmbin" ]; then
color $green
echo "$x is .bin file -- rm $x"
rm $x
color
else
echo "$x is .bin file -- nothing done"
fi
else
color $green
if [[ "$1" == rm* ]]; then
echo "bad file: -- $1 $x"
rm $x
else
echo "bad file -- mv $x $x.bin"
mv $x $x.bin
fi
color
fi
fi
done