-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-words.sh
executable file
·55 lines (49 loc) · 1.01 KB
/
find-words.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
#!/bin/bash
# Find all provided words
usage() {
cat <<EOF
Usage: find-words.sh [options] word...
Options:
--fuzzy Find inexact matches.
--lang=<lang> Set language. Available options: ru, en
--file=<file> File with list of words to find. Must be one word per line,
lines starting with '#' are ignored.
EOF
}
words=""
options=""
lang="en"
if [[ $# -eq 0 ]]; then
usage
exit 1
fi
while [[ $# -gt 0 ]]; do
case $1 in
--fuzzy)
fuzzy=1
options="$options -v inexact=1"
;;
--lang=*)
lang=${1##*=}
options="$options -v lang=$lang"
;;
--file=*)
file=${1##*=}
words=$(sed 's/^#.*//' "$file" | tr '\n' ' ')
;;
--*)
usage
exit 1
;;
*)
words="$1 $words"
;;
esac
shift
done
if [[ -z "$words" ]]; then
usage
exit 1
fi
gawk -f parse.awk $options JMdict $words
exit $?