home *** CD-ROM | disk | FTP | other *** search
- From: de5@ornl.gov (Dave Sill)
- Newsgroups: alt.sources,comp.misc,alt.folklore.computers
- Subject: Acronym lookup tool
- Message-ID: <1991Jan29.194237.12551@cs.utk.edu>
- Date: 29 Jan 91 19:42:37 GMT
-
- Disclaimer: provided without warranty as a public service. Use at
- your own risk.
-
- Send comments/additions to de5@ornl.gov.
-
- --8<--cut-here----
- #!/bin/sh
- #
- # NAME
- # whats - lookup acronym/abbreviation in database
- #
- # SYNOPSIS
- # whats [acronym [defn...]]
- #
- # DESCRIPTION
- # Whats, without any arguments, prompts for an acronym to look up.
- #
- # With one argument, whats prints all entries from the database
- # that match the argument. If no matches are found, whats
- # prompts for expansion of the acronym or abbreviation.
- #
- # With more than one argument, whats scans the database for
- # entries matching the first argument. If any matches are found,
- # whats prints the matching entries and asks if the remaining
- # arguments should be added as a new entry. If no matches are
- # found, a new entry is created for the first argument with the
- # remaining arguments forming the expansion.
- #
- # FILES
- # acron or $ACRON
- #
- # BUGS/DEFICIENCIES
- # Not blindingly fast.
- # Not tested under System V. (Uses "echo -n", "grep -i")
- #
- # AUTHOR
- # Dave Sill (dsill@nswc-oas.arpa) (de5@ornl.gov as of 6/90)
- # Naval Surface Warfare Center (NSWC), Dahlgren, VA
- #
- n='-n' # Use '' if your echo uses '\c'
- c='' # Use '\c' if your echo uses it
- q='-i' # Use '' or your grep's "ignore case" flag
-
- if [ -z "$1" ]
- then
- echo $n "What is what? $c"
- read ac
- else
- ac=$1
- fi
- ac=`echo ${ac} | tr "[a-z]" "[A-Z]"`
-
- if [ ! -f acron ]
- then
- acron=${ACRON}
- else
- acron=acron
- fi
- i=`grep $q -c "^${ac} " ${acron}`
-
- if [ -z "$2" -a $i -ne 0 ]
- then
- # No definition passed and is on file, so just do a lookup.
- grep $q "^${ac} " ${acron}
- exit
- elif [ $i -ne 0 ]
- then
- # Is on file and a definition was passed, check before adding.
- echo $i occurrences found.
- grep $q "^${ac} " ${acron}
- echo $n "Still want to add ${ac}? $c"
- read reply
- if [ "${reply}" = n -o "${reply}" = N ]
- then
- exit
- fi
- fi
- if [ -z "$2" ]
- then
- echo $n "What does ${ac} stand for? $c"
- read def
- if [ -z "${def}" ]
- then
- exit
- fi
- else
- shift
- def=$*
- fi
- echo "${ac} - ${def}" >>${acron}
- echo "${ac} - ${def}"
- --8<--cut-here----
-
- --
- Dave Sill (de5@ornl.gov) It will be a great day when our schools have
- Martin Marietta Energy Systems all the money they need and the Air Force
- Workstation Support has to hold a bake sale to buy a new bomber.
-