find-new-words.sh
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 08 Jan 2010 21:30:09 +0200
changeset 16 0c51714344e4
parent 10 8ba6bf51d9df
child 25 d0fcacd6421d
permissions -rwxr-xr-x
inefinit --> indefinite

#!/bin/sh

if [ -z $1 ]; then
  echo "Where dictionary?"
fi

if [ "$1" = --help ]; then
  echo find-new-words DICTIONARY
  echo   words read from stdin
  echo
  echo find-new-words DICTIONARY WORDS_FILE
  echo   words read from file
  exit 0
fi

dictionary=$1

if [ -z "$2" ]; then
  while true; do
    if read word; then
      if grep $word $dictionary >/dev/null; then
        :;
      else
        echo $word;
      fi
    else
      exit 0
    fi
  done
else
  while true; do
    if read word; then
      if grep $word $dictionary >/dev/null; then
        :;
      else
        echo $word;
      fi
    else
      exit 0
    fi
  done <$2
fi