Due: Wednesday, October 29, 2003 before class
When Woody Allen directs films, he often does not provide any of the
actors with a full script. Instead, each actor only sees the lines
for his or her own scene and has no further knowledge about
the film (presumably, he does this so that actors only focus on their
own character). For this assignment, suppose Woody Allen is
directing the Shakespeare play
Othello. We will use
UNIX tools to generate scripts for actors in the film.
Part I: AWK
Using a text version of the play stored in the file
/home/unixtool/data/othello.txt (note this should be equilvalent to the output from Assignment 2, Part III #1),
write an AWK script to print only the lines that IAGO will say, hiding
the lines that the other characters say.
Lines from the other characters that are "hidden" should not
be deleted. Instead they should be printed back with each letter of the
line (any char other than newline) replaced with the letter X.
Thus, the total number of output chars/lines should equal the total
number of input lines/chars.
A sample of some output is in /home/unixtool/data/othello.iago.txt.
Parsing: Assume a character's lines always start with a
single line consisting of all capital letters that has the
character's name. After the character's name is a blank
line, followed by one or more lines of what the character says,
followed by another blank line. Lines after that do not belong
to that character.
Special cases: You may decide whether or not to:
- Change the lines at the beginning of the play before the
first character's line to X's
- Hide the lines containing other character's names just
before their lines (i.e. the line RODERIGO).
Hide lines that do not belong to any character (after the
second blank line, before the next all-caps line).
Part II: shell
Write a UNIX shell script that allows us to do what we
did in Part I, but more generically for any character name in the play.
The script accepts a single argument
which is a character name, and changes the AWK script in
Part I to print out only the lines for that character.
Name the script outputscript. An example invocation
Which should only print out lines for RODERIGO.
There are a number of different ways you can change the AWK script.
It is up to you which commands you'd like to use. Some approaches
include (but are not limited to):
Send the AWK script as an argument using the character
name as a parameter, carefully using shell quoting rules.
Put the AWK script in a separate file and create a new
AWK script with the appropriate character name using sed, and
Use shell here documents.
Turning in the assignment
You should turn in the following:
Do not make assumptions about which directory the scripts are run from.
- AWK script for Part I. Name this iago.awk
- Shell script for Part II. Name this outputscript
- Files needed by Part II, if any
When you have finished, submit using the homework submission system.