find-new-words.sh
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 26 Sep 2010 18:27:31 +0300
changeset 184 0c984798a5d0
parent 32 785bc324c858
permissions -rwxr-xr-x
Reindent.

#!/bin/sh

if [ -z $1 ]; then
  echo "Where dictionary?"
  echo "Try $0 --help"
  exit 1
fi

if [ "$1" = --help ]; then
  echo Simple utility for searching word those not are in dictionary.
  echo Search done by grep.
  echo
  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