CSE 303, Autumn 2009
Homework 1: having a bash

Due Thursday, October 8, 2009, 11:30 PM
100 points total

No turn-in for Part I; Submit Part II via the Catalyst dropbox -- more information forthcoming; submit Part III via a Catalyst Quiz  (you are allowed to backtrack, edit, save and resume the quiz, and review it before submitting it)

This assign has three objectives related to basic use of Unix via the bash shell:
  1. Making certain you can login to an appropriate Unix machine. 
  2. Demonstrating that you have a basic knowledge of some key Unix concepts.
  3. Demonstrating that you can apply some basic Unix commands to perform simple computations and operations.
For most people, working with the actual commands may help build a better basic understanding of the concepts, so objectives 2 and 3 will be reversed in the actual assignment below. But you can do them in whatever order you prefer.

Part I: Using a Unix machine (6 points)
You will access to a Linux or other Unix environment for working on your homework for this course. There are several ways to do this: All our materials will address what is probably the easiest, most general solution: using attu.  The materials will be essentially the same if you login in one of the labs on a Linux box; if you run your own Unix system, there may or may not be differences: we're happy to take a quick look at some problems, but we will not be your system administrator (sysadmin) if you decide to roll your own. 
  1. Connect to attu.cs.washington.edu using ssh (which stands for secure shell).
    1. If you are on a Mac or Linux box, you can connect to the attu server by opening a Terminal window and typing the command
      ssh attu.cs.washington.edu
    2. Otherwise, to connect to attu we recommend that you install an SSH and SFTP shell / file transfer program for connecting to Linux servers, such as
      1. SSH Tectia (Windows).  To download SSH Tectia, click the Tectia link, and then on the page that appears, click the link "Download the software from our server. You must acknowledge agreement to the Export Regulations before you download." Then a "Software Export Regulations" page appears and you have to click "I Agree" to continue. You'll be given the link to download and install the program.
      1. Macs generally have a Terminal application installed that includes the ssh, sftp, and scp commands, so you probably don't have to install, but if you do you can try Secure Fetch or Fugu.
    1. If you have trouble finding or using ssh, please ask for help -- for this, you can ask anybody who knows how to find it and run it (including the 303 staff, of course).
  2. Change your shell to bash, and (optionally) change your password.
    1. The first time you connect, you must change your shell to bash by running the chsh command. When chsh asks you what shell you want to use, type /bin/bash.  Then logout and then reconnect to attu; it will remember your preference for bash from then on.  If when you enter chsh, you see an error like chsh: command not found -- then there is a problem with your "path" (that is, where Unix looks for programs to execute).  If this happens, for this, you can ask anybody who knows how to find chsh and run it (including the 303 staff, of course).
    2. Use passwd to change your password -- this isn't necessary if you've changed it recently.
There is no turn-in for Part I: but you can't do parts II and III without having done it.
Part II: Using basic Unix commands (44 points)

For each numbered item below, write a single bash shell statement that will perform the operation(s) requested.  For full credit, each of your solutions:
  1. List all files in the /var/lib directory, in the standard format (no special parameters required).
  2. List all files in /usr/share/dict, using the long format (-l flag).
  3. Find all lines in /usr/share/dict/linux.words (on attu -- equivalent if elsewhere) that have a double 'z' ("zz") in them (these must both be lower-case 'z').
  4. Find these same lines again and (as part of the same one-line shell statement) place them in the file zz.txt.
  5. Find all lines in the same file that have a double 'z' where either 'z' can be lower- or upper-case (that is, all four combinations "zz", "zZ", "Zz" and "ZZ" match) and place them in the file zz1.txt.
  6. Using zz.txt and zz1.txt, determine what additional matches, if any, are found when case is ignored.
  7. Count the number of lines in zz1.txt (do not count the number of characters or words, just lines).
  8. Create a subdirectory names assign1-scratch.
  9. In this subdirectory create a file ww.txt that contains all the lines in /usr/share/dict/linux.words that have a double 'w' (lower-case only).
  10. In this subdirectory, create a file wwzz.txt that contains all of ww.txt followed by all of zz1.txt.
  11. Display in alphabetical order all lines in wwzz.txt that contain a double 'o' (lower-case only).
In terms of grading, the points will come primarily from the correctness of your answers: Does the command you gave perform the action specified?  A point may be deducted from each item answered with an unnecessarily clunky or an unnecessarily slick solution -- we are looking for basic, solid solutions that are reasonable given a rudimentary understanding of a small set of Unix commands.

Note: The answers to all questions in this assignment can be phrased entirely using the commands ls, grep, cat, sort, and mkdir. You may use other commands if you like, but you should constrain yourself to those from lecture or from the Linux Pocket Guide textbook. Ask the staff if you are unsure whether a particular command is allowed.

Part III: Unix concepts -- and a few details to get you there (50 points)

Available now.