Lab09: Editing Files with vi


Objectives

     In this lab you will use the vi editor to create
     new files and edit existing files.

Procedure

     Log on to a Unix machine so that you have a command line shell at your
     service.  Change directory to edits to start this lab.

  1. Create a text file called home using vi and insert the following lines:
  2.         cd
            clear
            echo This is the home directory of $LOGNAME
            echo =======================================
            ls -F
  3. Use the chmod command to set the permissions on the file, home to -rwxr-xr-x.
  4. Enter the command home and see what happens. Is it what you would expect?
  5. Move this shell script you have just made to your bin directory,

  6. so that you may run it from anywhere on the system.
    Congratulations: you have just written your first shell script!
  7. Run the spell command on the file small_town:

  8. spell small_town
    Note all the misspelled words.
  9. Make a permanent list of the above misspelled words by running the spell command again, but this time, redirect the output to a file called, words.
  10. Use vi to edit the small_town file and correct all the misspelled words. Also get rid of duplicate lines and extraneous characters in the file. Use a consistent indentation.
  11. When you have fixed all the spelling errors, run the spell command again.

  12. What should be done with words like "Ayshire" and "moshpit" that aren't in UNIX's dictionary?
  13. Edit the file words and remove all the misspelled words that you have corrected. (Only Ayshire and moshpit should remain in the file.)
  14. Enter the following three commands from your shell prompt:
  15.        $ date
           $ echo Now is the time for all good men to come to the aid of their party
           $ cal
    Use command line editing to redisplay the echo command, and change the word men to women. Then reexecute the command. Hint: to enter command line editing mode, press the up-arrow key.
  16. Re-execute the command once more, but this time redirect the output to a file called women.
  17. Here is a little project for you to accomplish on a UNIX system:
  18. To get credit for this lab, you must send me the following five files that you have created or edited in this lab. I want these files bundled up into a single text file called lab09 and deposited in the directory:

  19. /home/jimg/cis90/$LOGNAME
    where $LOGNAME is your login name.
    The five files are:
            home
            words
            small_town
            women
            vocab
    One command that might do this could be:
    cat home words small_town women vocab > /home/jimg/cis90/$LOGNAME/lab09