author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 26 Sep 2010 18:38:42 +0300 | |
changeset 185 | 33f9b8e27659 |
parent 32 | 785bc324c858 |
permissions | -rwxr-xr-x |
10
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
#!/bin/sh |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
if [ -z $1 ]; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
echo "Where dictionary?" |
32
785bc324c858
If no arg provided warn and exit with error.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
25
diff
changeset
|
5 |
echo "Try $0 --help" |
785bc324c858
If no arg provided warn and exit with error.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
25
diff
changeset
|
6 |
exit 1 |
10
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
|
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
if [ "$1" = --help ]; then |
25 | 10 |
echo Simple utility for searching word those not are in dictionary. |
11 |
echo Search done by grep. |
|
12 |
echo |
|
10
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
echo find-new-words DICTIONARY |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
echo words read from stdin |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
echo |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
echo find-new-words DICTIONARY WORDS_FILE |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
echo words read from file |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
exit 0 |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
|
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
dictionary=$1 |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
|
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
if [ -z "$2" ]; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
while true; do |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
if read word; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
26 |
if grep $word $dictionary >/dev/null; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
27 |
:; |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
else |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
echo $word; |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
30 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
else |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
exit 0 |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
done |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
else |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
while true; do |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
if read word; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
38 |
if grep $word $dictionary >/dev/null; then |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
:; |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
40 |
else |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
echo $word; |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
42 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
43 |
else |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
44 |
exit 0 |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
45 |
fi |
8ba6bf51d9df
Simple utility for searching word those not are in dictionary.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
46 |
done <$2 |
25 | 47 |
fi |