文件中的行很长,我想从这种语法中提取字段名称...
decimal('\x01', maximum_length=10) trnsfl_err_tkt_trshold_1002 = NULL("\0"); /* Added for phase 3B May release INTERNAL VARIABLE*/
因此对于那一行,我想提取不带空格的trnsfl_err_tkt_trshold_1002
以下是该文件的示例,仅有几行:
decimal('\x01', maximum_length=4, sign_reserved) cld_sc = NULL("\0") /* Added for Phase 3B 20180104 BF */;
datetime("YYYYMMDDHH24MISS.NNNNNN")("\x01") cld_sc_ts = NULL("\0") /* Added for Phase 3B 20180104 BF */;
decimal('\x01', maximum_length=4, sign_reserved) cld_seg_cd = NULL("\0") /* Added for Phase 3B 20180104 BF */;
utf8 string('\x01', maximum_length=4) actn_rqst_cd = NULL("\0") /* Added for Phase 3B 20180125 Gurka */;
decimal('\x01', maximum_length=1) hram_prrty_rank_elig_in = NULL("\0"); /* INTERNAL VARIABLES */
decimal('\x01', maximum_length=4, sign_reserved) tcli_wk_excl_pass_in = NULL("\0"); /* Added for phase 3B May release*/
decimal('\x01', maximum_length=4, sign_reserved) tcli_wk_excl_rsn_cd = NULL("\0"); /* Added for phase 3B May release*/
date("YYYYMMDD")('\x01') rltm_last_perm_cr_lmt_updt_dt = NULL("\0") ; /* Added for phase 3B */
date("YYYYMMDD")('\x01') clinc_cmpgn_dt = NULL("\0"); /* Added for phase 3B May release*/
decimal('\x01', maximum_length=11, sign_reserved) clinc_rank_ordr_nb = NULL("\0"); /* Added for phase 3B May release*/
预期输出为:
cld_sc
cld_sc_ts
cld_seg_cd
actn_rqst_cd
hram_prrty_rank_elig_in
tcli_wk_excl_pass_in
tcli_wk_excl_rsn_cd
rltm_last_perm_cr_lmt_updt_dt
clinc_cmpgn_dt
clinc_rank_ordr_nb
答案 0 :(得分:1)
所以换句话说,您要提取第一个等号之前的最后一个标记
$ sed -E 's/.* ([^ ]+) =.*/\1/' file
cld_sc
cld_sc_ts
cld_seg_cd
actn_rqst_cd
hram_prrty_rank_elig_in
tcli_wk_excl_pass_in
tcli_wk_excl_rsn_cd
clinc_cmpgn_dt
clinc_rank_ordr_nb