Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your assignment is to write to a(Bash) shell scriptcalled pd.sh that prints a simple text database sorted on a specified field. The usage is as

Your assignment is to write to a(Bash) shell scriptcalled pd.sh that prints a simple text database sorted on a specified field. The usage is as follows:

pd.sh [ [-n] ]

The database_name is required, and the -n and field_name are optional. You should check that the database_name represents a valid database and the field_name (if specified) is one of the names of the fields defined 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. You should not include the comments when generating the table. You should then create a PDF file called table.pdf using the latex and dvipdf utilities. After, you should remove the tmp.tex, tmp.dvi, and any other temporary files and exit.

For instance, below is an example invocation of the pf.sh script.

# pd.sh cop4342 exam2

Assume for this example that cop4342 is a valid database name (i.e. in databases.txt), cop4342 has fields called name, exam1, exam2, and exam3 (i.e. in databases.txt), 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

Your shell script should produce a table of the data that would appear as:

name exam1 exam2 exam3

Ford 92 64 93

Smith 84 72 93

Green 72 72 72

Jones 85 73 94

Miller 93 73 87

The table formatting does not matter as long as the data is easily readable. The sorting does not have to be stable. You are not allowed to invoke other executables.

The following files work as follows:

databases.txt- contains the names of databases and its fields and it will look similar to this:

medical name age weight

course biology physics mathematics

cop4342 exam1 exam2 exam3

.db -contains the field values and looks something like the first example above.

table.pdf -The file created by running the shell script containing the database, database names, and the database values sorted.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

=+b) Cut the runs to 8 by testing only in hot water.

Answered: 1 week ago