Lab 01
Version 1

 

In this lab we will practice using emacs and some basic Unix commands, just to start getting the hang of things.

  1. Log in to your Orion account.

  2. Copy the file story01.txt from the CS 5 directory to the directory you are in using the command:
    cp /home/cs/cs5/story01.txt . 
    
    Don't miss the little dot that is the second argument to the command. It stands for "the directory I am in now".

  3. Load the file into Emacs using the command:
    emacs story01.txt  
    
    and make the following changes to the file:

    1. Delete the last paragraph, by using ctrl-k on each line. (Ctrl-K is the "kill line" command in emacs. Keep holding down the control key and hit the "k" key repeatedly until the paragraph is gone.)

    2. Put the paragraph you just deleted after the first paragraph. Do this by going to the beginning of the second paragraph and typing ctrl-y (for "yank"), which pastes the last killed block.

    3. Now let's use the search command, ctrl-s. When you type this, you get a prompt to enter what you wish to search for. As you start typing, emacs will immediately take you to the next bit of text that matches as much as you've typed up to that point. This is called an "incremental forward search". Let's search for all instances of the name Jack. Go to the beginning of the story and start the search command. Once you've found the first instance of the word "Jack", repeat the search, by just continuing hitting ctrl-s. Emacs will repeatedly find the next instance of the text you are searching for. The "incremental backwards search" works the same way, but is invoked with ctrl-r.

    4. Save your file (remaining in emacs) by typing ctrl-x then ctrl-s.

    5. Change all instances of the name Jack to your name. To do this use the find and replace command. Type esc-x and then the text replace-string. You will be prompted to enter the text you wish to replace and then the text you wish to replace it with. Emacs will then do all the replacements at once. If you prefer to be asked whether to replace each occurence, then, instead, type esc-x followed by query-replace (or just esc-%).

      Note, for all of these commands, make sure that you are at the beginning of the file. Otherwise they will only effect the part of the file below the point the cursor is at.

    6. Use ctrl-x and then ctrl-c to quit emacs. You will be asked if you wish to save this file. Save it by typing "y ", and then emacs will exit.

  4. Look at the contents of the file you just edited by typing:
    cat story01.txt 
    
    at the unix prompt.

  5. If the whole file didn't fit on your screen, view the file screen-by-screen by replacing cat with more in the last command.

  6. Print the story to the printer in the lab using the print command:
    print story01.txt 
    

  7. Change the name of the story you just edited. Do this by using the move command
    mv story01.txt newfile 
    
    where newfile is whatever name you want to give the file.

  8. See who else is on the system: try these commands: who and w and users.

  9. Try the date and uptime commands.

  10. Find out when your instructor was last on the system. Type:
    finger name 
    
    where name is your lab instructor's last name.

  11. Get some information about a unix command by typing:
    man command 
    
    where command is the command you want help with. Try getting information about some of the unix commands you just used.

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Tue, Sep 1, 1998 at 1:44:47 AM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_01/lab.html