Assignment 3:

Same instructions as always. One exception: if the output for a given command is really long, please use head and tail or a notation such as {...} to indicate that you've truncated output.

Set C. (Using /usr/share/dict/linux.words and /home/SRUNET/david.dailey/words)

Find and demonstrate a way to avoid typing the string "/usr/share/dict/linux.words" repeatedly in the following exercises.

1. Count the words in /home/SRUNET/david.dailey/words and in   /usr/share/dict/linux.words which contain the string "fy"

2. Count the number of words in  /usr/share/dict/linux.words that end in "o".

3. Display (in reverse alphabetical order) the first (alphatically earliest) ten words in  /usr/share/dict/linux.words which contain the substring "fy". That is, find the first ten words with that property, and display them in reverse alphabetical order.

4. Count the number of words in /usr/share/dict/linux.words which begin with a vowel (either upper or lower case) and end in "by".

5. Count the number of words in /usr/share/dict/linux.words which begin with a vowel (either upper or lower case) and end in "gy"

6. How many words in both /usr/share/dict/linux.words and /home/SRUNET/david.dailey/words contain no vowels, where vowels are defined to include upper and lowercase a, e, i, o, u, and y? Examine output to make sure it is correct.

Set D:

1. Below are the contents of a file and the contents as sorted in a particular way.

$ cat tweverse
two stubby
twelve wobble
three subbing
ten throbbing
six suburbia
seven swabbing
one stubborn
nine tabbing
four submersible
five suburb
eleven webbing
eight swabby
$ sort -k2 tweverse
one stubborn
two stubby
three subbing
four submersible
five suburb
six suburbia
seven swabbing
eight swabby
nine tabbing
ten throbbing
eleven webbing
twelve wobble

What did the 'sort -k2' command actually do? (By "actually do", I mean not merely some coincidence of  the spelling of  the names of numerals. )

2. How many words having exactly five, six and seven letters words are there in  /usr/share/dict/linux.words , /home/SRUNET/david.dailey/words,  and /home/SRUNET/david.dailey/data/wordstudy/BNCjustwords40583 ? (Show the commands used to get the count, and display a few lines of the actual output to verify correctness.) You output should contain  9 separate numbers (for each of the combinations of {5,6,7} x {file1,file2, file3} ) (Ask in class, prior to due date if this is unclear to you). 

3. w has been defined by w=/home/SRUNET/david.dailey/words

explain the difference between the following commands, why the output is different, and what each command actually did. [Hint: you may want to read a man file.]

$ grep -c ^[:alpha:]$ $w
1
$ grep -c ^[[:alpha:]]$ $w
4

4. Carry out the following transaction(s) and explain (in detail, at each step) what happens:

Note: the symbols surrounding `cat nums` are not single quotes or apostrophe's:  [']. Instead they are back-quotes: the character below the ~ at the upper left of the standard keyboard.

[ddailey]$ mkdir quote
[ddailey]$ cd quote
[quote]$ echo one two three four five
one two three four five
[quote]$ echo one two three four five > nums
[quote]$ ls
nums
[quote]$ for i in `cat nums`
> do
> echo $i >$i
> done
[quote]$ ls -l
total 6
-rw-r--r-- 1 ddailey faculty 5 Feb 22 17:04 five
-rw-r--r-- 1 ddailey faculty 5 Feb 22 17:04 four
-rw-r--r-- 1 ddailey faculty 24 Feb 22 17:01 nums
-rw-r--r-- 1 ddailey faculty 4 Feb 22 17:04 one
-rw-r--r-- 1 ddailey faculty 6 Feb 22 17:04 three
-rw-r--r-- 1 ddailey faculty 4 Feb 22 17:04 two

In particular how did the various files in that directory come into existence and how did they come to have differing file sizes?

Set E. (give a numeric answer for each --except #5; show the commands used to find the answer; demonstrate a sample of output to validate that your commands are working properly)

1. How many words in /usr/share/dict/linux.words begin with a capital letter? (show the commands used to find out)

2. How many words in  /usr/share/dict/linux.words have a capital letter in some position other than at the beginning?

3. How many words in  /usr/share/dict/linux.words contain three vowels in a row, where vowels include {a,e,i,o,u}? How many when vowels include {a,e,i,o,u, y}? You should be able to do this without listing all of them.

4. How many words  in  /usr/share/dict/linux.words contain two vowels (not including 'y') separated by exactly one character (either vowel or not). For example, 'exactly', and 'mandate' both do; 'mandible' and 'frantic' do not. You should be able to do this without listing all of them.

5. What is the last word in  /usr/share/dict/linux.words (alphabetically) which ends in an 'e'? You should be able to do this without listing all of them.

6. 'higgledy-piggledy' is the only word in w=/home/SRUNET/david.dailey/words that has the same seven letter sequence ('iggledy (with the exceptions of 'débouché' and 'résumé'  which are actually débouché and résumé * ) repeated twice. How many words have the same six letter sequence repeated twice (be careful not to include HTML entities like é for é ).

*Using this: 

$echo "débouché résumé"|./UniTrans
débouché résumé