File content modification

HI All,

I have a file with content as below
Filename:
my name is xyz
my name abc
my name is bdf
end
Filename:
my name uvx
my name edd
my name jhn
end
i want to edit the content and save into another file as
Filename1:
my name is xyz
Filename1:
my name abc
Filename1:
my name is bdf
Filename2:
my name uvx
Filename2:
my name edd
Filename2:
my name jhn

Please help me in finding the solution.
Regards,
Jhon.

Hi,

Try this one,

awk 'BEGIN{c=1;}$0 !~ /Filename/{if( $0 ~ /end/ ){c++;}else{print "Filename"c":\n"$0;}}' Input_File_Name

Cheers,
Ranga:)

Hi Ranga,

I need the solution in C language, sorry for not mentioning it.

Regards,
Jhon.

just use the same logic in C language if you know awk.

Cheers,
Ranga:)

Hi Ranga,

I don't know how exactly awk work.
Help me find the solution in c.

Regards,
Jhon.