Question
The Subject/Language is UNIX/Linux lab 1 - RegEx This lab complements our discussion on Regular Expression with three interesting puzzles. To solve the first two
The Subject/Language is UNIX/Linux
lab 1 - RegEx
This lab complements our discussion on Regular Expression with three interesting puzzles. To solve the first two puzzles, you will use a file that, in itself, is interesting, the DICTIONARY file.
The dictionary file, which has been included with Unix from the very beginning, contains a very long list of English words, including, most of the words commonly found in a concise dictionary. Each word is on a line by itself and the lines are in alphabetical order, which makes the file easy to search. Once you get used to using the dictionary file imaginatively, you will be able to do all kinds of amazing things. Some Unix commands such as look use the dictionary file to do their work.
NOTE: You might need to reinstall the dictionary file on your system: apt-get install --reinstall wamerican
The name of the dictionary file is words. In the early versions of Unix, the words file was stored in a directory names /usr/dict. In recent years, however, the Unix file structure has been reorganized and, on most modern systems including Linux and FreeBSD the words file is stored in a dictionary named /usr/share/dict. On a few systems, such as Solaris, the file is stored in /usr/share/lib/dict. Thus, the pathname of the dictionary file may vary from one system to another. Be sure to locate this file on your system and use it to solve the puzzles.
Now lets get to it:
1. To start, here is a simple puzzle. What are all the English words that begin with qu and ending with y. [Hint: Remember that each line of the dictionary file contains only a single word.]
2. The next puzzle is an old one. Find a common English word that contains all five vowels a, e, i, o, u in that order. The letters do not have to be adjacent, but they must be in alphabetical order. That is, a must come before e, which must come before i, and so on.
3. Our last puzzle involves a search of the Unix file system for historical artifacts. Many of the original Unix commands were two letters long; the text editor was ed, the copy program was cp, and so on. Let us find all such commands. To solve the puzzle, you need to know that the very oldest Unix programs reside in the /bin directory. There are other old Unix command in /usr/bin. Be sure to also provide a count of how many such commands there are.
Note: when you look in the /usr/bin, you may find some 2-character commands that are not old. To see if a command dates from the early days of Unix, check its man page. But you need not to implement this in your Regex.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started