COP4342 - Fall 2013 Assignment 3 Delete Records from a Simple Database

COP4342 - Fall 2013
Assignment 3
Delete Records from a Simple Database
Objectives: Learn how to use the for and break statements, numerical conditions, the expr operator, and the
awk command.
Instructions: Your assignment is writing a shell script called that deletes records from a simple text
database. It accepts as arguments a database_name, a field_name, and a field_value. You should check if
the database_name represents an existing database and if field_name is one of the names of the fields
defined in the schema for the specified database. If not, then you should print an appropriate error message
and exit. Assuming there is correct input data, you should remove any records from the database where the
value of that field matches the specified field_value and print a message indicating the number of records
deleted from the database.
For instance, below is an example invocation of the script.
% d cop4342 exam2 73
There were 1 records deleted from the cop4342 database.
Assume for this example that cop4342 is a valid database name (i.e. it is in the databases.txt file), it has a
schema called grades (i.e. defined in the databases.txt file), grades has fields called name, exam1, exam2,
and exam3 (i.e. defined in the schemas.txt file), and that a file exists called cop4342.db and it contains the
following data:
Smith 84 72 93
Jones 85 73 94
Ford 92 64 93
Your shell script should indicate that 1 record has been deleted and the cop4342.db file should now contain
the data:
Smith 84 72 93
Ford 92 64 93
While you are allowed to invoke other shell scripts that you have written and predefined Unix utilities, you
are not allowed to invoke other executables. If you need to store information into temporary files, then be
sure to delete these temporary files before you exit your script.
Submission: Submit the shell script and any other shell scripts that you used in this assignment as
separate attachments in a single e-mail message to via e-mail before the beginning of
class on 09/26/13.