Grep between 2 patterns in a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep between 2 patterns in a line
# 8  
Old 05-27-2010
Code update

Ok this is the actual file. Now you might understand why awk wont work. as the fields are not constant due to spaces in between.

Code:
18277 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_4_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_4_ M THTDTNH0weght +
18278 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_5_ ABC.hyuns.heksd.ut.mestyue_i.n_2837 M THTDTNH0weght +
18279 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_6_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_6_ M THTDTNH0weght +
18280 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_7_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_7_ M THTDTNH0weght +
18281 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_2_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_2_ M THTDTNH0weght +
18282 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_0_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_0_ M THTDTNH0weght +
18283 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_1_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_1_ M THTDTNH0weght +
18284 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_etl1_mijyt_m_ps_29_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_LKH_real_29_ M THTDTNH0weght +
18285 ABC.UCTSC.aghsty_4__teluths_0_ ABC.n_1452 M hGfD1TBCLVT +
18288 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .hu23019" LKHX JUHFD4TBC -
18289 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[1] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[1] .hu23019" LKHX JUHFD4TBC -
18290 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[2] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[2] .hu23019" LKHX JUHFD4TBC -
18291 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18292 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18293 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18294 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18295 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18296 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18297 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18298 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
19317 DEF.test_mu.gh_hitrate.hg_kil_etl1__srb_write_q_reg_0_ DEF.n_3130 M SDFKCNQD0weght +
19317 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___15_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_15_ M THTDTNH0weght +
19318 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___8_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_8_ M THTDTNH0weght +
19319 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___9_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_9_ M THTDTNH0weght +
19320 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___10_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_10_ M THTDTNH0weght +
19321 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___12_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_12_ M THTDTNH0weght +
19322 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___11_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_11_ M THTDTNH0weght +
19323 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___13_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_13_ M THTDTNH0weght +
19324 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___14_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_14_ M THTDTNH1weght +
187280 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .Xsdfg.Xghyr" DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.unused[28] LKHX JUHFD4TBC -
187281 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__280_ MsHJYTSS -
187282 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__208_ MsHJYTSS -
187283 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__136_ MsHJYTSS -
187284 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__64_ MsHJYTSS -
187285 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .Xsdfg.Xghyr" DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.unused[27] LKHX JUHFD4TBC -
187286 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__279_ MsHJYTSS -
187287 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__207_ MsHJYTSS -
187288 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__135_ MsHJYTSS -
187289 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__63_ MsHJYTSS -



---------- Post updated at 10:37 AM ---------- Previous update was at 10:35 AM ----------

@ dr.house

i got the following errors when i tried your code

Code:
PT="ABC.: Command not found.
PT: Undefined variable.

# 9  
Old 05-27-2010
Quote:
Originally Posted by naveen@
...
for e.g my input file has

Code:
"ABC.ABC__312.deftr_0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023" "ABC.ABC__312.asjartwtsj"
ABC.ABC__312.deftr0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023 ABC.ABC__312.asjasXCsaj
"DEF.DEF__312.deftr_0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023" "DEF.DEF__312.asjasdvsdj"
DEF.DEF__312.deftr0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023 DEF.DEF__312.asjasdfseqwj

I want to grep the words between the first occurence of ABC and DEF and next occurence of ABC and DEF that occurs with a preceeding space.

i.e output would be

Code:
"ABC.ABC__312.deftr_0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023" 
ABC.ABC__312.deftr0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023 
"DEF.DEF__312.deftr_0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023" 
DEF.DEF__312.deftr0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023

...
Code:
$
$ cat f1
"ABC.ABC__312.deftr_0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023" "ABC.ABC__312.asjartwtsj"
ABC.ABC__312.deftr0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023 ABC.ABC__312.asjasXCsaj
"DEF.DEF__312.deftr_0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023" "DEF.DEF__312.asjasdvsdj"
DEF.DEF__312.deftr0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023 DEF.DEF__312.asjasdfseqwj
"PQR.PQR__312.deftr_0.X143.Xntys_0.\Xetabc__PQR_test_tz[0] .X1023" "PQR.PQR__312.asjasdvsdj"
PQR.PQR__312.deftr0.X143.Xntys_0.\Xetabc__PQR_test_tz[0] .X1023 PQR.PQR__312.asjasdfseqwj
$
$
$ perl -lne '/^("*(ABC|DEF).*) "*(ABC|DEF).*/ and print $1' f1
"ABC.ABC__312.deftr_0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023"
ABC.ABC__312.deftr0.X143.Xntys_0.\Xetabc__ABC_test_tz[0] .X1023
"DEF.DEF__312.deftr_0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023"
DEF.DEF__312.deftr0.X143.Xntys_0.\Xetabc__DEF_test_tz[0] .X1023
$

tyler_durden

---------- Post updated at 03:00 PM ---------- Previous update was at 02:56 PM ----------

For the actual file -

Code:
$
$
$ cat f11
18277 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_4_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_4_ M THTDTNH0weght +
18278 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_5_ ABC.hyuns.heksd.ut.mestyue_i.n_2837 M THTDTNH0weght +
18279 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_6_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_6_ M THTDTNH0weght +
18280 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_7_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_7_ M THTDTNH0weght +
18281 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_2_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_2_ M THTDTNH0weght +
18282 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_0_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_0_ M THTDTNH0weght +
18283 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_1_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_1_ M THTDTNH0weght +
18284 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_etl1_mijyt_m_ps_29_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_LKH_real_29_ M THTDTNH0weght +
18285 ABC.UCTSC.aghsty_4__teluths_0_ ABC.n_1452 M hGfD1TBCLVT +
18288 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .hu23019" LKHX JUHFD4TBC -
18289 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[1] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[1] .hu23019" LKHX JUHFD4TBC -
18290 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[2] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[2] .hu23019" LKHX JUHFD4TBC -
18291 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18292 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18293 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18294 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1rtz__ABC_TagWay_TA0_rtz.hu23019" LKHX JUHFD4TBC -
18295 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18296 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18297 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
18298 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1__ABC_TagWay_TA0.M6750" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1__ABC_TagWay_TA0.hu2326" M GHFM4weght +
19317 DEF.test_mu.gh_hitrate.hg_kil_etl1__srb_write_q_reg_0_ DEF.n_3130 M SDFKCNQD0weght +
19317 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___15_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_15_ M THTDTNH0weght +
19318 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___8_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_8_ M THTDTNH0weght +
19319 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___9_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_9_ M THTDTNH0weght +
19320 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___10_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_10_ M THTDTNH0weght +
19321 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___12_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_12_ M THTDTNH0weght +
19322 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___11_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_11_ M THTDTNH0weght +
19323 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___13_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_13_ M THTDTNH0weght +
19324 DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___14_ DEF.test_mu.gh_hitrate.hg_kil_thgs_mes_14_ M THTDTNH1weght +
187280 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .Xsdfg.Xghyr" DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.unused[28] LKHX JUHFD4TBC -
187281 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__280_ MsHJYTSS -
187282 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__208_ MsHJYTSS -
187283 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__136_ MsHJYTSS -
187284 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__64_ MsHJYTSS -
187285 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .Xsdfg.Xghyr" DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.unused[27] LKHX JUHFD4TBC -
187286 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__279_ MsHJYTSS -
187287 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__207_ MsHJYTSS -
187288 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__135_ MsHJYTSS -
187289 "DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS" DEF.fe.Hul.Lys.LoU0_2_0__63_ MsHJYTSS -
$
$
$
$ perl -lne '/^\d+ ("*(ABC|DEF).*) "*(ABC|DEF).*$/ and print $1' f11
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_4_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_5_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_6_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_7_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_2_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_0_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_1_
ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_etl1_mijyt_m_ps_29_
ABC.UCTSC.aghsty_4__teluths_0_
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[1] .M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[2] .M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1rtz__ABC_TagWay_TA0_rtz.M895"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[0] .JuRl1__ABC_TagWay_TA0.M6750"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[1] .JuRl1__ABC_TagWay_TA0.M6750"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[2] .JuRl1__ABC_TagWay_TA0.M6750"
"ABC.ABC__889.hukas_0.M675.Xcrtz_0.\XTagWayGen[3] .JuRl1__ABC_TagWay_TA0.M6750"
DEF.test_mu.gh_hitrate.hg_kil_etl1__srb_write_q_reg_0_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___15_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___8_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___9_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___10_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___12_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___11_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___13_
DEF.test_mu.gh_hitrate.hg_kil_etl1__qual_ihm___14_
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .Xsdfg.Xghyr"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[7] .\HukL4[0] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .Xsdfg.Xghyr"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[3] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[2] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[1] .XIrdOutFlop.XIHJYTSS"
"DEF.fe.MULTI.GHIS.M_Gut.Xvrg.Xsty.\HukL16[6] .\HukL4[3] .\XTuIg[0] .XIrdOutFlop.XIHJYTSS"
$
$

tyler_durden
# 10  
Old 05-27-2010
Do i have to put this is an script? because when I try the same command it returns nothing. and the perl package is installed in /bin/perl on my system
# 11  
Old 05-27-2010
I believe that tyler's solution isn't returning anything for you because the numbers you listed in your actual file aren't in your actual file. If they were added by whatever tool you used to list the contents, then his code will not match any lines since they don't begin with one or more digits. If I am correct, you can tweak his perl to the following:
Code:
perl -lne '/^("*(ABC|DEF).*) "*(ABC|DEF).*$/ and print $1' file

Regards,
Alister

---------- Post updated at 03:15 PM ---------- Previous update was at 03:13 PM ----------

I just realized that that's exactly what he was using on your initial data sample. :P
# 12  
Old 05-27-2010
No luck yet Smilie But The output posted by him is exactly what I need.
# 13  
Old 05-27-2010
Quote:
Originally Posted by naveen@
No luck yet Smilie But The output posted by him is exactly what I need.
Ok, then it's time for some D&C Smilie

Run the following command on the prompt and copy/paste the command as well as its output from your Terminal session over here:

Code:
head <my_input_file>

Replace the string <my_input_file> with the name of your input file.

tyler_durden
# 14  
Old 05-27-2010
Done.. Here is what i Got
Code:
[naveen]: head f
     18277 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_4_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_4_ M THTDTNH0weght +
     18278 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_5_ ABC.hyuns.heksd.ut.mestyue_i.n_2837 M THTDTNH0weght +
     18279 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_6_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_6_ M THTDTNH0weght +
     18280 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_etl1_mijyt_m_ps_7_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__GHytnem__7_0_LKH_real_7_ M THTDTNH0weght +
     18281 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_2_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_2_ M THTDTNH0weght +
     18282 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_0_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_0_ M THTDTNH0weght +
     18283 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_etl1_mijyt_m_ps_1_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__PHTem__2_0_LKH_real_1_ M THTDTNH0weght +
     18284 ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_etl1_mijyt_m_ps_29_ ABC.hyuns.heksd.ut.mestyue_i.mestnem_i.etl1soo__OpCodeRWVec2__31_0_LKH_real_29_ M THTDTNH0weght +
     18285 ABC.UCTSC.aghsty_4__teluths_0_ ABC.n_1452 M hGfD1TBCLVT +
     18288 "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .M895" "ABC.ABC__889.hukas_0.M675.Xcrtz_0.\JuRl1rtz__ABC_TagOp_TA0_rtz[0] .hu23019" LKHX JUHFD4TBC -

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep multiple patterns(file) and replace whole line

I am able to grep multiple patterns which stored in a files. However, how could we replace the whole line with either the pattern or new string? For example: pattern_file: *Info in the () is not part of the pattern file. They are the intended name to replace the whole line after the pattern... (5 Replies)
Discussion started by: wxboo
5 Replies

2. Shell Programming and Scripting

Find matched patterns and print them with other patterns not the whole line

Hi, I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
Discussion started by: redse171
3 Replies

3. Shell Programming and Scripting

Grep patterns

Hi Experts, I have a log file like this.I need to filter the Index name and elapsed time(only created ). 06:36:39 SQL> create index XYZ_F75 on XYZ 06:36:39 2 ("GRP_ID", "_ID") parallel 64 nologging 06:36:39 3 tablespace XARGS_IDX 06:36:39 4 ; Index created. Elapsed:... (2 Replies)
Discussion started by: navsan420
2 Replies

4. Shell Programming and Scripting

comment a line of the patterns is a the beginning of the line

I need to comment the lines starting with pattern "exclude" or "exclude=". If the work exclude comes at any other part, ignore it. Also, ignore, excludes, excluded etc. Ie only comment the line starting with exclude. File contents. exclude exclude= hi I am excluded excludes excludes= ... (9 Replies)
Discussion started by: anil510
9 Replies

5. UNIX for Dummies Questions & Answers

Grep - various patterns

I have a file with the following text: grep \$ grep \\$ grep \\\$ grep '\$' grep '\'$' grep \\ grep \\\\ grep "\$" grep '"$' grep "$" When I perform these same commands on this file, the result are never what I would expect them to be. Could someone please comment on the results and... (3 Replies)
Discussion started by: uran101
3 Replies

6. Shell Programming and Scripting

grep value between two patterns

Hi All, I've been trying solve this with a simple command but not having much luck. I have a file like this: Line 1: random_description 123/alert/high random_description2 356/alert/slow Line 2: random_description3 654/alert/medium Line 3: random_description4 234/alert/critical I'm... (7 Replies)
Discussion started by: joe19
7 Replies

7. Shell Programming and Scripting

grep for multiple patterns

I have a file with many rows. I want to grep for multiple patterns from the file. For eg: XX=123|YY=222|ZZ=566 AA=123|EE=222|GG=566 FF=123|RR=222|GG=566 DD=123|RR=222|GG=566 I want the lines which has both XX and ZZ. I know I can get it like this. grep XX file | grep YY But... (10 Replies)
Discussion started by: tene
10 Replies

8. Shell Programming and Scripting

Grep All lines between 2 different patterns

I need a simple script to get all lines between 2 Patterns, e.g. ............. ............. 114456723: testing Script Alpha Beta 114459234: testing Done ............. ............. It should give all the lines in between 114456723 and 114459234, including these as well. Any... (2 Replies)
Discussion started by: gurpreet470
2 Replies

9. Shell Programming and Scripting

grep patterns - File

Hi I have 3 patterns for example to be searched. These three patterns are available in file1. The patterns to be searched are in file2. I want to search the pattern of file1 to file2. Can any one help with example? Regards Dhana (1 Reply)
Discussion started by: dhanamurthy
1 Replies

10. Shell Programming and Scripting

Grep multiple patterns

Hi, Can we grep multiple patterns in UNIX. for example: cat /x/y/oratab | grep -i "pattern1|pattern2" .... etc I require the syntax for multiple patterns. | is not working as I explained in example. Malay (4 Replies)
Discussion started by: malaymaru
4 Replies
Login or Register to Ask a Question