Afficher un message
Vieux 22/05/2007, 20h55   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: extract lines from file

sonal10july@gmail.com wrote:
> Hi Friends,
>
> I want all those lines lines from file starting with keyword 'INSERT'
> and end with ')'
> Note: In following example there are two ')' (one after 'INSERT' and
> another after 'VALUES') . I want all those lines between INSERT and
> second occurence of ')'


It's really hard to decipher your data [ - I hope that someday people
would take more care about how they present their data structures - ].

But you may try whether the following code suffices for your request...

awk '/INSERT/,/)/;/VALUES/,/)/' < inputfile > output_file


Janis


> ############
> Input File
> ################################################## #########################
> INSERT common..dividend
> ( dividend_id,tid,declared_date,ex_date,record_date, pay_date,amount,interim_final_flag,
>
> fx_rate,stock_option_ratio,stock_price,treaty_tax_ rate,non_treaty_tax_rate,currency_code,
>
> create_date,update_date,create_user_id,update_user _id,cam_id,orig_cam_id
> )
> VALUES (306181, 51758, '2007-05-11', '2007-05-21',
> '2007-05-21', '2007-05-24', 0.19,
> 'I', 0.7426385949277784, null, 4.818, null,
> null, 'EUR', '2007-05-11 03:04', '2007-05-11 03:04',
> 105,
> 105, 19874739, null
> )
>
> May 21, 2007 6:17:11 PM com.esdi.dividend.DividendAccrual
> accrueDividends
> INFO: START of accrual process for tid: 51745
> May 21, 2007 6:17:11 PM com.esdi.dividend.DividendAccrual
> accrueDividends
> INFO: Instrument tid is 51745
>
> INSERT common..dividend (
>
> dividend_id,tid,declared_date,ex_date,record_date, pay_date,amount,interim_final_flag,
>
> fx_rate,stock_option_ratio,stock_price,treaty_tax_ rate,non_treaty_tax_rate,currency_code,
>
> create_date,update_date,create_user_id,update_user _id,cam_id,orig_cam_id
> )
> VALUES (306177, 51745, '2007-05-11', '2007-05-21',
> '2007-05-21', '2007-05-24', 0.015,
> 'I', 0.7426385949277784, null, 1.381, null,
> null, 'EUR', '2007-05-11 03:04', '2007-05-11 03:04',
> 105,
> 105, 19874793, null
> )
>
> ################################################## #########################
>
> Output should be like following
> ======================
> INSERT common..dividend
> ( dividend_id,tid,declared_date,ex_date,record_date, pay_date,amount,interim_final_flag,
>
> fx_rate,stock_option_ratio,stock_price,treaty_tax_ rate,non_treaty_tax_rate,currency_code,
>
> create_date,update_date,create_user_id,update_user _id,cam_id,orig_cam_id
> )
> VALUES (306181, 51758, '2007-05-11', '2007-05-21',
> '2007-05-21', '2007-05-24', 0.19,
> 'I', 0.7426385949277784, null, 4.818, null,
> null, 'EUR', '2007-05-11 03:04', '2007-05-11 03:04',
> 105,
> 105, 19874739, null
> )
> INSERT common..dividend
> ( dividend_id,tid,declared_date,ex_date,record_date, pay_date,amount,interim_final_flag,
>
> fx_rate,stock_option_ratio,stock_price,treaty_tax_ rate,non_treaty_tax_rate,currency_code,
>
> create_date,update_date,create_user_id,update_user _id,cam_id,orig_cam_id
> )
> VALUES (306181, 51758, '2007-05-11', '2007-05-21',
> '2007-05-21', '2007-05-24', 0.19,
> 'I', 0.7426385949277784, null, 4.818, null,
> null, 'EUR', '2007-05-11 03:04', '2007-05-11 03:04',
> 105,
> 105, 19874739, null
> )
>
>
> Thank you all in advance for your .
>
> Regards
> SK
>

  Réponse avec citation
 
Page generated in 0,06335 seconds with 9 queries