-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·53 lines (46 loc) · 1.3 KB
/
compile.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
#array=( $(eval echo $(cat words_2ch.txt)) )
#array=( $(cat words_2ch.txt) )
#for e in "${array[@]}"; do
# echo "#exp(/^$e /i) |" >> compiled.txt
# echo "#exp(/ $e /i) |" >> compiled.txt
# echo "#exp(/ $e$/i) |" >> compiled.txt
#done
######rm compiled_final.txt
#while read -r char; do
# echo "#exp(/^$char[,.?!]? /im) |" >> compiled.txt
# echo "#exp(/ $char[,.?!]? /im) |" >> compiled.txt
# echo "#exp(/ $char[,.?!]?$/im) |" >> compiled.txt
#done < words_2ch.txt
# shellcheck disable=SC1087
compile() {
while read -r char; do
{
echo "#exp(/^$char[,.?!]? /im) |"
echo "#exp(/ $char[,.?!]? /im) |"
echo "#exp(/ $char[,.?!]?$/im) |"
echo "#exp(/^$char[,.?!]?$/im) |"
} >> compiled.txt
done < "words_${1}.txt"
cat "other_${1}.txt" >> compiled.txt
head -c-2 > compiled_final.txt < compiled.txt
rm compiled.txt
xsel -ib < compiled_final.txt
}
# shellcheck disable=SC1087
compile1() {
#local rules
if [[ -e "words_${1}.txt" ]]; then
while read -r char; do
{
echo "#exp(/^$char[,.?!]? /im) |"
echo "#exp(/ $char[,.?!]? /im) |"
echo "#exp(/ $char[,.?!]?$/im) |"
echo "#exp(/^$char[,.?!]?$/im) |"
} >> compiled.txt
done < "words_${1}.txt"
fi
cat "other_${1}.txt" compiled.txt | head -c-2 | xsel -ib
rm compiled.txt
}
compile1 "${1}"