-
Notifications
You must be signed in to change notification settings - Fork 0
/
bruteforce_rule_first.sh
executable file
·40 lines (31 loc) · 1.05 KB
/
bruteforce_rule_first.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
#!/bin/bash
FILEOUT=./db/az_first_10_rule.txt
MIN=${1:-10}
chars="abcdefghijklmnopqrstuvwxyz'"
n=27
echo save to ${FILEOUT}
echo '' > ${FILEOUT}
for ((i=0; i<n; i++))
do
for ((j=0; j<n; j++))
do
# for ((k=0; k<n; k++))
# do
echo ${chars:i:1}${chars:j:1}
T=`cat ./db/all_true_rule.txt | grep -E "^${chars:i:1}${chars:j:1}" | wc -l`
F=`cat ./db/all_false_rule.txt | grep -E "^${chars:i:1}${chars:j:1}" | wc -l`
PT=$(echo "($T / ($T + $F + 1)) * 100" | bc -l)
if [[ $(echo "if ( ($F > 0) && (${PT} < ${MIN}) ) 1 else 0" | bc) -eq 1 ]]; then
echo -e "${chars:i:1}${chars:j:1}\t${PT}\t${T}\t${F}" >> ${FILEOUT}
fi
# done
done
done
cat ${FILEOUT} | sed -r 's/\t\./\t0,/g' | sed -r 's/\./,/g' | sort -n -k 2 > /tmp/2
cp /tmp/2 ${FILEOUT}
echo
cat ${FILEOUT} | cut -f 1 | tr -s '\t\r\n' ','
echo
# cat file_az10_rule.txt | head -n 15 | cut -f 1 | tr -s '\r\n' ','
# cat ./file_first_az10_rule.txt | head -n 67 | cut -f 1 | tr -s '\r\n' ','
# cat ./file_last_az10_rule.txt | head -n 87 | cut -f 1 | grep -E "[a-z']{1}[^']" | tr -s '\r\n' ','