Dear friends, Please help me to resolve the problem below,
I have a file with following content:
date of file creation : 12 feb 2007
= name : suresh
= city :mumbai #this is a blank line
= date : 1st Nov 2005
few lines of some text
this text could be of any number of lines
= code : 10
= time : 10AM
= job : dev
====================
= name : mahesh
= city :Bangalore #this is a blank line
= date : 1st april 2005
few lines of some text
this text could be of any number of lines
= code : 0
= time : 11AM
= job : test
====================
= name : Girish
= city :Pune #this is a blank line
= date : 4april 2005
few lines of some text
this text could be of any number of lines
= code : 15
= time : 12AM
= job : support
#end of file
in the above data, it contains 3 records(marked using blue, green and magenta colours).
now the problem is, I need to store all the line of a record which is having the "=code : 10" in a file file_10
and
"=code : 15" in a file file_15.
and
if the "=code : 0" then I need to ignore that record and continure with next record till the end of file.
above script is ok, but I need this for generic case, i.e., I need to cluster the records having similar "code" into individual files,
for example,
all the records having code=10 need to be stored in a file called code_10 file and
all the records having code=15 need to be stored in a file called code_15 file ...etc.
the code number varied from 0 to 255.
and if the code is 0 then we can ignore those recors.
and if input file contains codes 0,10,15,20, then the script should generate only 3 files(for 10, 15,20) ignoring 0.