You are on page 1of 2

Fundamentals of Computing (ES102) Lab#3

1 Use vi to create a file called “exam1” with the text below, with the following requirements:
 Make sure the text have the beginning and ending lines of equal signs ( = )
 Make sure you have the exact same number of lines (hit the enter key when you get to the
end of each line of text)
 You don’t have to have the exact number of equal signs as shown
 For the numbered item, there is one space between the number and the text

========================================
these are the services that an operating
system (os) such as Linux performs:
1. the os decides which application to
run at any instant in time
2. the os performs the management of
memory
4. when there are operation errors, the
os reports these errors to the
application
5. the os provides tools for the user
to perform basic services
========================================

2. Save file “exam1” to another file called “exam2”. Then save “exam1” and quit
from vi.

3. Use vi to open “exam2”. Look for the number 2 in the text. Move to the correct place
in the current line and use one command to delete the last part of the current line so it reads:
2 the os performs
Then move to the next line and use one command to add at the end of the line so it looks
like:
memory management

4. Use one command to look for the number 4, then use one command to insert the
following text in the proper place in “exam2”
3 the os controls access to hardware
devices

5. Go to the first line of the file. Then search for the word “app” and stop at the second
instance of “app” (you’ll be at the word “application” of item 4). Use one command to add the
phrase “and the user” to the end of item 4 so it reads:
4 when there are operation errors, the
OS reports these errors to the
application and the user
6. Go to the first word in the file and use one command to change the “t” to uppercase, so
the first word is: These
Save the file “exam2” to continue at the next lab time
--------------------------------------------------------------------
--
7. Use vi to open file “exam2”

8. Use one vi command to find all instances of the word “os” and replace with “OS”

9. Reverse the order of the items numbered 1,2,3,4,5 (so they are in the order 5,4,3,2,1) by
using cut and paste commands in vi. Re-order the actual text along with the numbers, don’t just
renumber each item. You should only have to use 4 cut and 4 paste commands.

10. Add a blank line in between all the numbered items. Take advantage of the “repeat”
command so you only open a new line and use escape once.

11. Look for the number 2 in the file, then use one command to turn the two lines of item 2
into one line:
2 the OS performs memory management

12. Save “exam2” and quit out of vi.

13. Use vi to open your script output file from step 1 of Module 3. Stay in vi and append
“exam1” and “exam2” (in that order) to the end of the script output file.

14. Clean up the module 3 portion of your script output file. This means remove all
commands that result in error messages, all extra commands that are not part of this lab, all
typing mistakes, and all control characters (except ^M). This step could be viewed as torture, but
it’s supposed to give you practice and motivation to learn vi well.

15. Print and turn in a clean script output file. Points will be deducted if you turn in the “raw”
script output file.
From this lab on, you only turn in one copy of your lab work. You can: 1) print from voyager
and pick up the print out at school, or 2) transfer your lab work to your home computer and print
from home.

You might also like