Search between two search strings and print the value

Based on the forums i have tried with grep command but i am unable to get the required output.

search this value /------
If that is found then search for temp_vul and print
and also search until /
------- and print new_vul

Input  file contains:

/*-----------------------------------------------------------------*/
   temp_vul : abcdefghijklmnopqu
   -----
   -----
   -----
   -----
   -----
   -----
   new_Vul: asdasjdlkajsdlasdlkj
   -----
   -----
   -----
   -----

/*------------------------------------------------------------------*/

   temp_vul : abcdefghijklmnopqu
   -----
   -----
   new_Vul: asdasjdlkajsdlasdlkj
   -----
   -----
   -----
   -----

/*--------------------------------------------------------------------*/
   temp_vul : abcdefghijklmnopqu
   -----
   -----
   -----
   -----
   new_Vul: asdasjdlkajsdlasdlkj
   -----
   -----
   -----
   -----

/*-------------------------------------------------------------------*/

Output Value:
temp_vul : abcdefghijklmnopqu
new_Vul: asdasjdlkajsdlasdlkj
temp_vul : abcdefghijklmnopqu
new_Vul: asdasjdlkajsdlasdlkj
temp_vul : abcdefghijklmnopqu
new_Vul: asdasjdlkajsdlasdlkj

Any help greatly appriciated

Thanks
onesuri

Grep should have worked if you do not care about the presence of /*---- pattern before the searched strings. If it matters, post back, otherwise use below command.

cat <input_file> | grep -E "(temp_vul)|(new_Vul)"

It will print entries after /*---- and only first two values.(it stops after new_value)

awk '/^\/\*-----/{s=1}
s && /temp_vul/{print}
s && /new_Vul/{print;s=""}' file

Hi,

it is working fine but tried to add print options to keep in the same line. but it is not working.

Output Value:
temp_vul : abcdefghijklmnopqu ~ new_Vul: asdasjdlkajsdlasdlkj
temp_vul : abcdefghijklmnopqu ~ new_Vul: asdasjdlkajsdlasdlkj
temp_vul : abcdefghijklmnopqu ~ new_Vul: asdasjdlkajsdlasdlkj

Thanks
onesuri

Use printf

awk '/^\/\*-----/{s=1} s && /temp_vul/{printf $0} s && /new_Vul/{print " ~ "$0;s=0}' infile

--ahamed

Tried the below command but it is not giving output.
If no value then it should not print the value.

Source File:

Input  file contains:

/*-----------------------------------------------------------------*/
   temp_vul : abcdefghijklmnopqu
   -----
   -----
   -----
   -----
   -----
   -----
   new_Vul: asdasjdlkajsdlasdlkj
   -----
   -----
   -----
   -----

/*------------------------------------------------------------------*/

   temp_vul : abcdefghijklmnopqu
   -----
   -----
   -----
   -----
   -----
   -----
   -----

/*--------------------------------------------------------------------*/
   temp_vul : abcdefghijklmnopqu
   -----
   -----
   -----
   -----
   new_Vul: asdasjdlkajsdlasdlkj
   -----
   -----
   -----
   -----

/*-------------------------------------------------------------------*/



Output Value:
temp_vul : abcdefghijklmnopqu ~ new_Vul: asdasjdlkajsdlasdlkj
temp_vul : abcdefghijklmnopqu ~ new_Vul: asdasjdlkajsdlasdlkj