CSCI 435: Compiler Construction
Assignment 3

Overview

Use grep -E and its regular expressions (REs) to perform matching on the dictionary file /usr/share/dict/words. You MUST use our dictionary file or your counts will be incorrect. Do NOT use pipes, avoid unnecessary quoting, and keep your REs as SIMPLE as possible. Be sure to consult the grep man page ("man grep" or grep(1)).

We will define a "letter" as one of 'a', 'b', ..., 'z', with NO case distinction. If for one of the searches below you find zero words, construct your own test file to ensure your RE is correct.

Search for the following:

  1. words containing the substring "quid" (or "Quid", "quId", etc.)

  2. words that start and end with the same letter, including one letter words

  3. words that contain two occurrences of an IDENTICAL (case matters) substring of length 4

  4. words with the same letter 3 times in a row

  5. words that have 20 or more letters in them

  6. words of length j, where 16 ≤ j ≤ 20 (any character counts toward the length, including an apostrophe)

  7. words that have all 5 vowels (a, e, i, o, u) (case insensitive)

  8. words that lack vowels

  9. words that contain a SINGLE hyphen

  10. words with all 5 vowels in alphabetical order, with no intervening vowels to break the sequence

Show ONLY word counts, and not the matching words! Modify this Bash script to echo and answer all of the above questions, following the example format. Use newline characters to skip TWO lines after each count. Answer the questions in the ORDER above.

Output Specification

Output what you're searching for followed by the number of matches. Skip two lines between answers. Do NOT output anything for question 0.

Output Format

1. words containing the substring "quid" (or "Quid", "quId", etc.)
<number>


2. words that start and end with the same letter, including one letter words
<number>


...

Submission

Submit your Bash script file (use an extension of ".sh").

Further Exploration

No extra credit will be awarded for answering these questions. Linux COMMANDS can be used to answer the first three questions.

  1. What directory contains the grep man page?

  2. What file format is used to store the man page on disk?

  3. What typesetting language was used to write the man page?

  4. Can the man page be translated into other computer languages? Elaborate.


Gary M. Zoppetti, Ph.D.