CSCI 3194 (Seminar (UNIX Power Tools)), Fall 2014:
Homework 2
- Credit:
- 40 points.
Be sure you have read the assigned readings for classes through 10/22.
Answer the following questions. You may write out your answers by
hand or using a word processor or other program, but please submit
hard copy, either in class or in my mailbox in the department office.
Answers to most questions will involve experimentation on
a UNIX or Linux system.
You are free to use any appropriate system
(unless a specific problem says otherwise);
if you use something other than one of our classroom/lab machines
please tell me what.
- (8 points)
Spend at least half an hour (more if you have the time and
interest) working through the vim
tutorial (and/or reading other parts of the
online help). Start the tutorial by typing
vimtutor at the command prompt.
Access online help by typing
:help or :help sometopic; exit help by
typing :q.
Then tell me at least two things you
learned that you didn't know before and you think
you might find useful.
(If you have already read part of this tutorial for
a previous class, read further in it than you have before.)
- (8 points)
Repeat the previous question, but with the emacs
tutorial and/or online help. Start it by typing
emacs and then control-h followed by t.
Access online help as described in the tutorial.
By default emacs will create a new window if it can.
If you don't want that, start it with emacs -nw.
(If you have already read part of this tutorial for
a previous class, read further in it than you have before.)
- (4 points)
Which editor do you feel more inclined to learn more about
at this point (considering features, ease of use, etc.).
Why? (``Neither'' is an acceptable answer if you explain why!)
Do the following programming problems. You will end up with at
least one code file per problem.
Submit your program source (and any other needed files)
by sending mail to
bmassing@cs.trinity.edu,
with each file as an attachment.
Please use a subject line that mentions the course number and
the assignment (e.g., ``csci 3194 homework 2'').
You can develop your programs on any system that provides the
needed functionality, but I will test them on one of the department's
Linux machines, so you should probably make sure they work
in that environment before turning them in.
- (10 points)
Do one of the following:
- Write a shell script that renames a file (specified as
a parameter), changing any
blanks in its name to underscores.
If no filename is given, or if the file does not exist,
the script should print an error message.
Hint: See the examples in the class notes
and the example scripts on the
sample programs page.
- Write a shell script that makes use of a conditional
(if/then/else/fi) and at least one positional
parameter and does something you find useful or interesting.
Include comments at the top of the script describing its
purpose.
- (10 points)
Do one of the following:
- Write a shell script that searches all directories in
your search path for a specified file/executable and prints
the directories where it is found. For example, if the
script is called find-in-path,
find-in-path ls would print /bin or
/bin/ls.
If the specified file is found in more than one directory,
the script should print them all. If it is not found at
all, the script can print an error message or just do
nothing. If no file/executable is specified, the script
should print an error message.
Hint: See the examples in the class notes
and the example scripts on the
sample programs page.
- Write a shell script that makes use of a loop
(for or while)
and does something you find useful or interesting.
Include comments at the top of the script describing its
purpose.
Berna Massingill
2014-10-22