find-new-words.sh
changeset 10 8ba6bf51d9df
child 25 d0fcacd6421d
equal deleted inserted replaced
9:976f8876799d 10:8ba6bf51d9df
       
     1 #!/bin/sh
       
     2 
       
     3 if [ -z $1 ]; then
       
     4   echo "Where dictionary?"
       
     5 fi
       
     6 
       
     7 if [ "$1" = --help ]; then
       
     8   echo find-new-words DICTIONARY
       
     9   echo   words read from stdin
       
    10   echo
       
    11   echo find-new-words DICTIONARY WORDS_FILE
       
    12   echo   words read from file
       
    13   exit 0
       
    14 fi
       
    15 
       
    16 dictionary=$1
       
    17 
       
    18 if [ -z "$2" ]; then
       
    19   while true; do
       
    20     if read word; then
       
    21       if grep $word $dictionary >/dev/null; then
       
    22         :;
       
    23       else
       
    24         echo $word;
       
    25       fi
       
    26     else
       
    27       exit 0
       
    28     fi
       
    29   done
       
    30 else
       
    31   while true; do
       
    32     if read word; then
       
    33       if grep $word $dictionary >/dev/null; then
       
    34         :;
       
    35       else
       
    36         echo $word;
       
    37       fi
       
    38     else
       
    39       exit 0
       
    40     fi
       
    41   done <$2
       
    42 fi