Question: Your assignment is write to a shell script called pd.sh that prints a simple text database sorted on a specified field. The usage is as
Your assignment is write to a shell script called pd.sh that prints a simple text database sorted on a specified field. The usage is as follows:
pd.sh
The database_name is required and the -n and field_name are optional. You should check that the data- base_name represents a valid database and the field_name if specified is one of the names of the fields defined in the schema for the database. If not, then you should print an appropriate error message and exit. The database should be printed as a table and should be sorted in order of the values associated with the field_name. If no field_name is specified, then you should sort in the order of the values of the first field. If -n is specified, then you should perform a numeric sort rather than an ASCII sort on the specified field. You should create a table in a file called tmp.tex using the format described in the Latex Table Example slide presented in class. However, you should right justify all of the fields in the table. You should not include the comments when generating the table. You should then create a pdf file called tmp.pdf using the latex and dvipdf utilities and view it using acroread as described in the Latex Example (cont.) slide presented in class. After displaying the table, you should remove the tmp.tex, tmp.dvi, tmp.pdf, and any other temporary files and exit. For instance, below is an example invocation of the pf.sh script.
pd.sh cop4342 -n exam2
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 Miller 93 73 87 Green 72 72 72 White 92 72 86 Johnson 90 85 80 Douglas 90 60 70 Lewis 80 64 70 Brown 92 70 93 Daniels 85 80 80
Your shell script should produce a table of the data that would appear as:
(basically sorted in a table with a heading of name, exam1, exam2, exam3)
(should be sorted numerically by which column is chosen so if exam2 then 60,64, 64, 70 (somehow using -k3 but also putting the names in that order like douglas, ford, lewis, brown)
(also the names and grades should be centered under each heading)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
