CSCI 3294 (Seminar: UNIX Power Tools), Fall 2016:
Homework 3
- Credit:
- 20 points.
Be sure you have read, or at least skimmed,
the assigned readings for 9/14.
Please include with each part of the assignment the Honor Code pledge or
just the word ``pledged'', plus one or more of the following about
collaboration and help (as many as apply).1Text in italics is explanatory or something for you to
fill in.
For written assignments, it should go right after your name and
the assignment number; for programming assignments, it should go
in comments at the start of your program.
- This assignment is entirely my own work.
- This assignment is entirely my own work, except for portions
I got from the assignment itself
(some programming assignments include ``starter
code'')
or sample programs for the course (from which you
can borrow freely -- that's what they're for).
- I worked with names of other students on this
assignment.
- I got help with this assignment from source of help -- ACM
tutoring, another student in the course, the instructor, etc.
- I got significant help from outside source --
a book other than the textbook (give title and author),
a Web site (give its URL), etc..
(``Significant'' here means more than just a little
assistance with tools -- you don't need to tell me that you
looked up an error message on the Web, but if you found
an algorithm or a code sketch, tell me about that.)
- I provided significant help to names of students on this
assignment.
(``Significant'' here means more than just a little
assistance with tools -- you don't need to tell me about
helping other students decipher compiler error messages,
but beyond that, do tell me.)
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 and
the assignment (e.g.,
``csci 3294 hw 3'' or
``UNIX hw 3'').
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.
Probably it should also print a message if the old and
new names would be the same.
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.
Footnotes
- ... apply).1
-
Credit where credit is due:
I based the wording of this list on a posting to a SIGCSE mailing
list. SIGCSE is the ACM's Special Interest Group on CS Education.
Berna Massingill
2016-11-22