-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfind.sh
executable file
·57 lines (50 loc) · 1.33 KB
/
find.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
54
55
56
57
usage() { echo "Usage: $0 [-f folder] [-w word]" 1>&2; exit 1; }
while getopts "f:w:" o; do
case "$o" in
f)
s="$OPTARG"
if [ ! -d "$OPTARG" ] ; then
echo "ERROR: $OPTARG should be a directory.";
usage
fi
;;
w)
c="$OPTARG"
if [ -z "$OPTARG" ] ; then
echo "ERROR: input -w empty"
usage
fi
;;
*)
usage
;;
esac
done
shift "$((OPTIND-1))"
if [ -z "$s" ] ; then
echo "ERROR: input -f empty"
usage
fi
if [ -z "$c" ] ; then
echo "ERROR: input -w empty"
usage
fi
if [ ! -d $PWD"/find_result" ] ; then
mkdir find_result
fi
if [ ! -f $PWD"/logs.txt" ] ; then
touch $PWD"/logs.txt"
chmod 777 $PWD"/logs.txt"
fi
echo "---------------------Execution started:" $(date -u) "-----------------" >> $PWD"/logs.txt"
chmod 777 $PWD"/find_result"
COUNTER=0
for entry in "$s"/*
do
chmod 777 "$entry" >> $PWD"/logs.txt"
COUNTER=$((COUNTER + 1)) >> $PWD"/logs.txt"
touch $PWD"/find_result/file${COUNTER}.txt" >> $PWD"/logs.txt"
chmod 777 $PWD"/find_result/file${COUNTER}.txt" >> $PWD"/logs.txt"
pdftotext "$entry" $PWD"/find_result/file${COUNTER}.txt" >> $PWD"/logs.txt"
done
python3 find_python.py "$c"