CSCI 3294 (Unix Power Tools), Fall 2009:
Homework 3
- Credit:
- 20 points.
Read about the following topics
in the list of suggested readings,
either in one of the suggested readings or
in another book or reference.
(This is the topic for September 23):
Do the following programming problems. You will end up with at
least one code file per problem. Turn in your code by sending mail
to bmassing@cs.trinity.edu, with each of your code files as an
attachment.
Please use a subject line that mentions the course number and
the assignment (e.g., ``csci 3294 homework 3'').
If there's any question of which file(s) correspond to
which problems, explain in the body of the mail message.
You can develop your programs on any system that provides the
needed functionality, but I will test them on one of the department's
Fedora 11 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
2009-09-28