Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want a code in unix. Below is text file called medslist. Code should be according to program requirements. Write a Unix /bin/bash program to

I want a code in unix. Below is text file called "medslist". Code should be according to program requirements.

image text in transcribedimage text in transcribedimage text in transcribed

Write a Unix /bin/bash program to search a medication list and produce a report as requested by the user. The file medslist is a flat plain text file with the following format shown in the table below. Columns Data field 01-04 Category 05 - 12 Medication Code 13 - 25 Generic Name 26 - 39 Dose 40 - 46 On-Hand (inventory) Example of the " medslist " file... (The first two lines represent columns numbers, not in file) 0 1 2 3 4 5 6 123456789012345678901234567890123456789012345678901234567890 commA6314 ifosfamide 30 12 home5341209 urokinase 6314 etc. Program Requirements Continually prompt the user to enter a Medication Code or portion thereof (should not have to re-run program for each search). Use "ZZZ to exit program from the "Enter Medication Code" prompt. Ask the user if s/he wishes to see the corresponding Generic Name (G/g) or Dose (D/d); reject any other input with an error message ("Please enter only G or D.'') and re- prompt user continually if necessary. Search only the Medication Code field of the data file displaying the all occurrences of matching Medication Code (s) and corresponding Generic Name or Dose. E.g. A search for the Medication Code "6314", should not display any information about Medication Code "5341209". i.e. the search must be restricted to the information in the Medication Code field. Print a separator character (e.g. colon) between the information fields (see sample output). Include partial matches of Medication Code (e.g. 234 is contained in Medication Code 12345). Keep the search case-sensitive. Use the sample data file from the course website. Sample file is not exhaustive or representative of all situations. For example, don't expect particular values in the Category field (only letters, etc.) to limit your search of the Medication Code field. If no match is found, output "No such Medication Code." If you create any temporary files, they must be cleaned up by your program before it terminates. Your program must perform its search and report strictly based on column numbers. The data file may contain any type of character in any field. (e.g. do not assume that the Medication Code consists of only numbers or that the Dose must contain letters) Your program must not use any text processing utilities like awk, sed, or perl. You must not modify the given data file. Your program must work on any data file of the format given above - not just the given sample data file. Sample execution (not exhaustive testing): $ ./search Enter Medication Code? 6314 See Generic Name (G/g) or Dose (D/d)? G A6314 :ifosfamide Enter Medication Code? 23 See Generic Name (G/g) or Dose (D/d)? j Please enter only G or D. See Generic Name (G/g) or Dose (D/d)? d 12345 : ug 200 9230 : pg 6000 Enter Medication Code? foo See Generic Name (G/g) or Dose (D/d)? D No such Medication Code. Enter Medication Code? ZZZ Good bye. 30 commA6314 ifosfamide home5341209 urokinase 6314 educ 12345candesartin ug home32493320doxorubicin m^2 homeEH-1101 anti-ebo m^2 comm9230 garimycin pg comm6807 haemogen-RL23units home 86197820EH-1101 m^2 agri36B-987623-cisplantinL 12 37 200 3268 40-80 40-80 71 6000DNO 0 40000 40-95 286 250 108

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions