Starting from:
$18.99

$12.99

Assignment 3 Solution

Background

In this assignment, in addition to the commands covered in the previous homework, we work with filters and commands such as grep and introduce sed and tr.

Part I. This part uses polls.csv. Copy the new file to your assignment 3 sub directory before using it.(2 points each)

·  Show a list of all the polling organizations.

·  Count the number of unique polling organizations.

Part II: The Dictionary and Regular Expressions

The answers to these questions require using the command grep, in some cases wc, and the dictionary file (/usr/local/tmp/Words). The dictionary is case sensitive; keep this in mind when writing your grep commands. Also, for the purposes of these questions, only a, e, i, o and u are vowels (not y), and a consonant is any character that is not a vowel (including punctuation).

First, take a look at the contents of (/usr/local/tmp/Words). Note that each word has two entries. In normal and reverse order. In addition, the first letter of each word is upper case.

1.   Using tr, convert all upper case letters to lower case. (1 points)

2.   Using sed, remove the reversed copy of each word. [hint] Each word is followed by it's reverse on subsequent lines. Save the output of this command as a file named "words" in your home dir for use with the remaining questions. (3 points)

3.   Count the number of five letter words in the dictionary. (1 points)

4.   Count the number of 7 letter words in the dictionary that start with the letter "a" . (2 points)

5.   Output all the words in the dictionary [$HOME/words] that have exactly six consonants (non-vowels) in a row. (4 points)

When you have finished, submit as before, upload a file named userid.assignment3.txt using the CSE dropbox .

 

More products