extract the contents from file to a new file

Hi

i would like to extract some part of the file to a new file.

first I would like to search for a string in the file and then i want two or three line above from the string to the the required string(can be any character)

I would like this to be made generalized in a script

Thanks

Show the input you want and the output you want.

you can use the "grep -B" option if I understood you right.

Hi
Example
Input:

{1:F01NWSCUS33XXXX0000000000}{2:I571AGNGDXXN}{4:
:28:1/0 
:20:AGD
:83D:513324
:67A:111004
:30:111005
:35H:SHS80000,000000
:35B:CUSP 003830106
DISC
:32H:USD200000.000000
:72:TR1175566\\RF 00100000\\CTC\\NT003\
\HV200000\\MV200000\\OD20110503
1234
{1:F01NWSCUS33XXXX0000000000}{2:I571AGNGDXXN}{4:
:28:2/0 
:20:AGD
:83D:513324
:67A:111004
:30:111005
:35H:SHS80000,000000
:35B:CUP 003830106
1234

OUTPUT:
First i would like to search the string containg 83D i.e(513324) and then i would like to copy the data from first line i.e({1:F01NWSCUS33XXXX0000000000} to the last line which is a constant string i.e(1234 here)of that 83D string.

i need to give the parameter of 83D manually every time and need to extract till the string 1234 to a new file

Thanks a lot

Still not clear....can you paste the output you want please.

grep -A9 -B3 ":83D:" infile