CS21: Week2, In-Class Exercises for Thursday

  1. If you have not already done so create a week2 subdirectory in your cs21 subdirectory:
    % cd           # remember you can use ls and pwd to figure out where you are in the directory tree
    % cd cs21
    % mkdir week2
    % cd week2
    % pwd                # should list /home/yourusername/cs21/week2
    
  2. From your week2 subdirectory copy over files from my week2 directory:
    % cd ~/cs21/week2                       # change to your week2 subdirectory
    % pwd
    % cp ~newhall/public/cs21/week2/NestedLoops.java  .     
    % cp ~newhall/public/cs21/week2/StarPattern.java  .     
    % cp ~newhall/public/cs21/week2/Makefile  .     
    % ls	        
    
    If you want to move a file from one directory to another, you can use the mv command. For example, if you accidently copied over the StarPattern.java file into your cs21 subdirectory and you really wanted it in your week2 subdirectory, you could do the following:
     % cd ~/cs21                         # change to (move into) your cs21 directory
     % mv StarPattern.java  week2/.	     # mv source_file destination_file
     % ls                                # StarPattern.java should no longer be in current directory, cs21
     % cd week2                          # move into your week2 subdirectory
     % ls                                # should list StarPattern.java
    

  3. We are going to look through these programs together. Lets start by opening NestedLoops.java in vim (or emacs):
    % vim NestedLoops.java