-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommonRabinger
54 lines (46 loc) · 1.16 KB
/
commonRabinger
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
#!/bin/bash
#rabin2 -zzz $i | awk -F " " '{print $8}'
#removes results file if it already exists
rm results_commonStrings.txt
#It would be convinient to remove spaces from filenames, otherwise it could break the script
#FOO=' test test test '
# FOO_NO_SPACES="$(echo -e "${FOO}" | sed -e 's/^[[:space:]]*//')"
#take every file in current folder and output its strings in separate files inside tmp/
for i in *; do
name="strings_$i.txt"
rabin2 -zzz $i | awk -F " " '{print $8}' > $name
#sort the strings
sort -u $name > tmp.txt
rm $name
mv tmp.txt $name
done
#delete strings file for this script
rm strings_commonStringer.sh.txt
mkdir tmp
mv strings_* tmp/
cd tmp
#make $name equal to the last file of tmp/
for i in *; do
name=$i
done
#compare the string_ files with each other looking for common strings
thisfile="commonStringer.sh"
act=0
for i in *; do
echo ""
echo "comparing $name and $i"
#skip this script file for the comparation
if [[ $i == $thisfile ]] ; then
continue
fi
tmpname="tmp_$act.txt"
comm -12 $name $i > aux.txt
name=$tmpname
mv aux.txt $name
#cat $name
act=$(($act + 1))
done
#cat $name
mv $name ../results_commonStrings.txt
cd ..
rm -r tmp/