Find Words - match

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Appendix D.  Sample Korn Shell Scripts


Find Words - match

The match command uses Korn shell pattern-matching characters to find words in a dictionary. It can be used to help with crossword puzzles, or test your patterns.

 #!/bin/ksh  #  #     match - Korn shell word-finder  #  # Check usage  if (($# < 1 || $# > 2))  then        print "Usage: $0 pattern [file]"        exit 1  fi  # Check/set DICT to word dictionary  : ${DICT:=${2:-/usr/dict/words}}  # Open $DICT for input  exec 0<$DICT  # Read each word into WORD  while read WORD  do        # This command didn't work on all systems. If        # it doesn't on yours, use this instead of        # exec 0<$DICT:        #     cat $DICT | while read WORD        #        # If WORD matches the given pattern,        # print the match        [[ $WORD = $1 ]] && print - $WORD  done 

       
    Top
     



    Korn Shell. Unix and Linux Programming Manual, Third Edition
    Korn Shell. Unix and Linux Programming Manual, Third Edition
    ISBN: N/A
    EAN: N/A
    Year: 2000
    Pages: 177

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net