nnani
August 26, 2013, 10:37am
1
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.
Subbeh
August 26, 2013, 11:02am
2
Try this:
awk '/Define schema/{p=1;getline;next} /\)\;/{p=0} p{print}' file
RudiC
August 26, 2013, 12:07pm
3
Try also
awk '/Define schema/,/\)\;/ {if (NF==2) print}' file
a varchar(20)
,b varchar(30)
,c varchar(40)
nnani
August 27, 2013, 2:42am
4
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
RudiC
August 27, 2013, 3:22pm
5
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...)