I need to create a script called 'find_data' that will search a file by passing two parameters to it
. I'm pretty good with scripting but haven't really gotten into sed and awk that much (and no perl whatsoever). I'm really at a loss and need to get something working in the next couple days (yes, we still do work on weekends).
The script should work like this.
find_data <parameter 1> <parameter 2>
The first parameter would be the data before the colon (':').
The second parameter would be the data after the colon (':')
If both are found the data between the preceeding BEGINJOB and ENDJOB (inclusive) should be displayed to stdout.
Examples using the data:
1 find_data start 01:15 would find, and display, the first set of data.
2 find_data days tu would find, and display, the last set of data.
3 find_data days all would find, and display, the 2nd, 3rd and 4th sets of data.
I really appreciate your help with this. It's a great site.
Sample data (only five shown but there are several hundred):
BEGINJOB---------------------------
insert_job: cir_cdezp07b job_type: c
command: /apps/usr/circ/bin/cdezp07b.cmd
days_of_week: all
start_times: "01:15"
description: "Mass Zip Code Update"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsds03b job_type: c
command: /apps/usr/circ/bin/ccsds03b.cmd
days_of_week: all
start_times: "02:00"
description: "Deletes Info. from Dispatch_table"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsda78r job_type: c
command: /apps/usr/circ/bin/ccsda78r.cmd REP
days_of_week: all
start_times: "03:00"
description: "Daily Reports"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsda95i job_type: c
command: /apps/usr/circ/bin/ccsda95i.cmd 6 1000 0 25
days_of_week: all
start_times: "04:00"
condition: s (cir_ccbdd01b_daily) & s (cir_ccbdd01b_sat) & s (cir_ccbdd01b_sun)
description: "Archive job, runs M-SU"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_cdtsm01i job_type: c
command: /apps/usr/circ/bin/cdtsm01i.cmd
days_of_week: tu,we,th,fr,sa
start_times: "04:00"
description: "Templated Solo Mail - aoets20b.tx to aoets20b_txt"
ENDJOB