Extract Parts of File

Hello All,

I have a file like this

Define schema flat_file_schema
(
a varchar(20)
,b varchar(30)
,c varchar(40)
);
(Insert into table (
a
,b
,c
) values
(
1
,2
,3
);

I need to extract
a varchar(20)
,b varchar(30)
,c varchar(40)
out of this file and put in other file for looping.

I tried it with this

awk '/Define schema/ {t=1} f && /\)/{exit} f; /\(/ && t {f=1}' file

But this does not give any output
How can I do this.

Try this:

awk '/Define schema/{p=1;getline;next} /\)\;/{p=0} p{print}' file

Try also

 awk '/Define schema/,/\)\;/ {if (NF==2) print}' file
a varchar(20)
,b varchar(30)
,c varchar(40)

Hello All,

The original file format is like this

USING CHARACTER SET UTF8 DEFINE JOB 

(

DEFINE SCHEMA Flat_File_Schema
(
  cntnt_id VARCHAR(10)
  div_id VARCHAR(10)
);

DEFINE OPERATOR o_mload
 TYPE update
 SCHEMA *
 ATTRIBUTES
  (
    VARCHAR TdpId           = @TdpId
  );
DEFINE OPERATOR o_tpump
 TYPE stream
 SCHEMA *
 ATTRIBUTES
  (
    VARCHAR TdpId           = @TdpId
  );
DEFINE OPERATOR o_bteq
 TYPE inserter
 SCHEMA *
 ATTRIBUTES
  (
    VARCHAR TdpId           = @TdpId
  );
DEFINE OPERATOR o_fastload
 TYPE load
 SCHEMA *
 ATTRIBUTES
  (
    VARCHAR TdpId           = @TdpId
   ,VARCHAR UserName        = @UserName 
  );
DEFINE OPERATOR Read_Operator
 TYPE DATACONNECTOR PRODUCER
 SCHEMA Flat_File_Schema
 ATTRIBUTES
  (
    VARCHAR FileName         = @FileName 
);

APPLY
( 'INSERT INTO cntnt_cat_itm (
  cntnt_id
 ,cat_itm_nm
 ,prnt_cat_itm_nm
 ,updt_dt_tm
 ,load_dt_tm
 ,src_tbl_nm
 ,trans_type_cd
 ,jrnl_seq_nbr
 ,commit_locl_tm_zn
 ,batch_dt
 ,batch_id
 ) VALUES
(
 :cntnt_id
 ,cat_itm_nm
 ,prnt_cat_itm_nm
 
 
 );'
)
    IGNORE DUPLICATE ROWS
    SELECT * FROM OPERATOR (Read_Operator[@ReadInst]);
);

I need the highlighted text to be given as the output in different commands for each part
The above commands is not working for this

Of course "the above commands is not working for this", as you requested sth totally different in your first post. How would you expect it to work, then?

(And, besides, I'd bet your spec in post#4 is far from being complete as well...)