I am trying to develop a script which should find a word if a particular word exists.
Below is the content of the file.
insert_job: test_job ----> job name
days_of_week: all
start_times: "16:00"
date_conditions: 1
insert_job: test_job2 ----> job name
days_of_week: all
start_times: "16:00"
Now my objective is to find the job name which doesn't have date_conditions even though they have both start_times and days_of_week.
In the above sample it should display test_job2 as output as it doesn't contain days_of_week and start_times.
thanks for your reply on my query.
The code which you have sent is not working. As I mentioned in my query. The script needs to check whether job name(its under insert_job) contains days_of_week and start_times parameter then only it should go for checking date_conditions parameter.
If there are no days_of_week and start_times parameter for a particular job name it should skip that job.
If job name contains both days_of_week and start_times parameter and if it doesn't contain date_conditions parameter it should print job name else not.
At the end of the script it should print only job name thats under insert_job parameter.
I am facing a new problem. I want to remove line which is having blank space above and below to it.
Below is the sample file.
insert_job: fsetlbqa_fsw_ibsfile_box job_type: b
date_conditions: 1
start_times: "09:00"
insert_job: fsetlbqafsw028ibsetlfile job_type: c
insert_job: fsetlbqa_fsw_ETLB_spc_rep_box job_type: b
date_conditions: 1
days_of_week: mo,tu,we,th,fr,sa,su
start_times: "06:00"
insert_job: fsetlbqafswW999spacereport job_type: c
My output should be
insert_job: fsetlbqa_fsw_ibsfile_box job_type: b
date_conditions: 1
start_times: "09:00"
insert_job: fsetlbqa_fsw_ETLB_spc_rep_box job_type: b
date_conditions: 1
days_of_week: mo,tu,we,th,fr,sa,su
start_times: "06:00"
I want to remove the lines which are blank spaces above and below to the line. I am trying to get it done by using sed. But i am not getting correct solution.
/insert/ --> have insert in the line , store the line in "q" and go to next line
if "q" is not empty print it and make "q" empty.
for your input ,
insert_job: fsetlbqafswW999spacereport job_type: c
First line is blank , so step (1) is matched , hence will go to next line
For second line ,step(2) is matched , since the line have "insert" in to. so store it in "q' and go to next line
For third line , agian it's blank , so step(1) will be matched and will make "q" empty and go to next line.