Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I understand that this question is already answered, but the syntax is not working in Ubuntu. I would like to have the answer which is
I understand that this question is already answered, but the syntax is not working in Ubuntu. I would like to have the answer which is compatible both in Unix and Ubuntu.
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 home 5341209 urokinase 6314 37 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 Gor 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 byeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started