Question: Design both a C-program and a shell-script program controlling the C program. 1. Re-design a C program according to the following requirements. The C program



Design both a C-program and a shell-script program controlling the C program. 1. Re-design a C program according to the following requirements. The C program must read "test.txt" and find only females who are more than 30 and less than 50 years old. Create partial_people_female_30_50.c using three arguments - argv[1]-thefirstargument:aninputfilename. - argv[2]-thesecondargument:astartinglineoftheinputfile. - argv[3]-thethirdargument:anendinglineoftheinputfile. Extract person ids corresponding to persons who are female, and more than 30 and less than 50 years old from argv[2] to argv[3] in argv[1]. If you did not download test.txt for argv[1], check lab 2. Figure 1. Example of the input file (i.e., test.txt) Let us assume that partial_people_female_30_50 is an executable file of partial_people_female_30_50.c. For example, ./partial_people_female_30_50 test.txt 14 means partial_people_female_30_50 reads lines (four numbers) from line 1 to line 4 and checks females who are more than 30 and less than 50 years old from test.txt. You do not need check household ids. Based on Figure 1 for an input, partial_people_female_30_50 reads only the lines from "126774361 405498149291 " to "126774363 405498151492 " from test.txt, and returns 3 (i.e., the number of person ids). 2. Create a shell script program, called partial_female_30_50.sh to control partial_people_female_30_50 (i.e., the executable file of partial_people_female_30_50.c).partial_femail_30_50.sh also has three arguments like partial_people_female_30_50.c. - \$1: the input file - \$2: a starting line of the input file - \$3: an ending line of the input file Check the lines of an input file (Use wcl$1 to check the number of lines). If the number of lines of the input file is less than $2 or $3, echo "out of range". Otherwise, execute partial_people_female_30_50 \$1 \$2 \$3. After the execution, check whether partial_people_female_30_50 is terminated successfully. If it is not terminated successfully, echo "error". If it is terminated successfully, the shell program MUST display a number of the extracted person ids. Note that, the shell program -- partial_female_30_50.sh has to receive the result from partial_people_female_30_50, so the shell program does not need to open and read the input file. Hint: To execute partial_people_female_30_50 in a shell program, use "\$(./partial_people_female_30_50 \$1 \$2 \$3)". To check whether it terminates successfully, use $
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
