Intro to Unix Midterm Exam

This test was very disappointing. The fact that so few people did well reflects on my teaching methods. These are basic unix operations that you should be familiar with -- at least until the test is over.

1.  [2]  Open a new bash shell

bash
This turned out to be harder to detect in your output than I expected.
2.  [8]  Create a new directory and make it current for the following steps.
mkdir TestDir; cd TestDir
   [4]         [4]
3.  [25]  In a single command line, count the number of times the 1st of a month fell on Saturday (hint look for more than two spaces after the single numeral 1) in the year 2000.
cal 2000 | grep " 1   " | wc -l
   [4]  [5] [5]   [5]    [5] [2]
Note that grep produces one line of output for every line of its input containing a string matching the pattern, so wc can just count lines. There are no months in 2000 where the 1st fell on a Saturday at the end of a line.
4.  [25]  In one command line, create in your new directory a new text file consisting of all the files (user names) in the directory "/users/students" with two consecutive vowels in their user names, and sorted reverse alphabetically.
ls /users/students/ | grep "[aeiou][aeiou]" | sort -r > afile
   [5]             [3] [4]       [4]             [5]  [4]
Although it's not obvious, ls sends file names one per line when piped to another command. Thus grep can just pick out the lines with consecutive vowels and send them to sort.
5.  [10]  Open this file in a (unix) text editor such as vi or emacs, and globally change all the letters "s" in the file to "SOS".
These two steps (5 and 6) don't leave any particular trace in the history, but I expected to see in the printout that you succeeded.
6.  [10]  Move the last line to the top of the file. Insert in front of it your own name followed by a blank line, then save the file.

7.  [15]  Using a single command line, add to the end of your text file today's date, followed by a history of the commands you used so far to take this test, and print the result.

date >> afile; history >> afile; lpr afile
   [5]      [5]                   [5]
8.  [5]  Turn in your printed output. If you make too many mistakes, you may need to start over so the printed history has all your commands.
 

First draft 2004 March 10
Scoring added March 12