CMSC 435: Assignment 2
Overview
Use grep -E and its regular expressions (RE-s) 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 RE-s 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’, ‘a’, ‘B’, ‘b’, …, ‘Z’, ‘z’. 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 words below.
words containing the substring “quid” (or “Quid”, “quId”, etc.)
words that start and end with the same letter (case matters), including one letter words
words that contain two occurrences of an IDENTICAL (case matters) substring of length 4
words with the same (case matters) letter 3 times in a row
words that have 20 or more letters in them
words of length
j, where \(16 \le j \le 20\) (any character counts toward the length, including an apostrophe)words that have all 5 vowels (a, e, i, o, u) (case insensitive)
words that lack vowels
words that contain a SINGLE hyphen
words with all five 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 (which is included in the script).
Sample Output
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>
...
What to Submit
Submit your Bash script file Grep.sh.
Further Exploration
No extra credit will be awarded for answering these questions. Linux COMMANDS can be used to answer the first three questions.
What directory contains the grep man page?
What file format is used to store the man page on disk?
What typesetting language was used to write the man page?
Can the man page be translated into other computer languages? Elaborate.
Gary M. Zoppetti, Ph.D.