From: Harry on 25 Feb 2010 15:16 I have about 30 text files containing some MQ object definitions. I want to locate some CHANNEL definitions with a pattern "SSLCAUTH(REQUIRED)". For example: $ find . -type f -exec grep -l SSLCAUTH\(REQUIRED\) {} \; ../host1/Q_MANAGER1.log ../host1/Q_MANAGER2.log ../host2/Q_MANAGER3.log ../host2/Q_MANAGER4.log ../host3/Q_MANAGER5.log ../host3/Q_MANAGER6.log .... The text before and after the pattern are like this : DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + * ALTDATE (2009-07-24) + * ALTTIME (23.03.53) + TRPTYPE(TCP) + DESCR(' ') + HBINT(300) + MAXMSGL(4194304) + MCAUSER(' ') + RCVDATA(' ') + RCVEXIT(' ') + SCYDATA(' ') + SCYEXIT(' ') + SENDDATA(' ') + SENDEXIT(' ') + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + SSLPEER(' ') + KAINT(AUTO) + MONCHL(QMGR) + COMPMSG(NONE) + COMPHDR(NONE) + REPLACE DEFINE QUEUE <blablabla> .... What I want is a shell cmd that can print (for each channel definition inside a Q_MANAGER log) : (1) the DEFINE CHANNEL line before the pattern (2) the SSLCAUTH(REQUIRED) line (3) the SSLCIPH line N.B. The number of lines between (1) & (2) may vary, while (3) usually follow (2). Please help. Thanks
From: Ed Morton on 25 Feb 2010 15:39 On Feb 25, 2:16 pm, Harry <harryooopot...(a)hotmail.com> wrote: > I have about 30 text files containing some MQ object definitions. > I want to locate some CHANNEL definitions with a pattern > "SSLCAUTH(REQUIRED)". > > For example: > > $ find . -type f -exec grep -l SSLCAUTH\(REQUIRED\) {} \; > ./host1/Q_MANAGER1.log > ./host1/Q_MANAGER2.log > ./host2/Q_MANAGER3.log > ./host2/Q_MANAGER4.log > ./host3/Q_MANAGER5.log > ./host3/Q_MANAGER6.log > ... > > The text before and after the pattern are like this : > > DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + > * ALTDATE (2009-07-24) + > * ALTTIME (23.03.53) + > TRPTYPE(TCP) + > DESCR(' ') + > HBINT(300) + > MAXMSGL(4194304) + > MCAUSER(' ') + > RCVDATA(' ') + > RCVEXIT(' ') + > SCYDATA(' ') + > SCYEXIT(' ') + > SENDDATA(' ') + > SENDEXIT(' ') + > SSLCAUTH(REQUIRED) + > SSLCIPH(' ') + > SSLPEER(' ') + > KAINT(AUTO) + > MONCHL(QMGR) + > COMPMSG(NONE) + > COMPHDR(NONE) + > REPLACE > > DEFINE QUEUE <blablabla> > ... > > What I want is a shell cmd that can print (for each channel > definition inside a Q_MANAGER log) : > (1) the DEFINE CHANNEL line before the pattern > (2) the SSLCAUTH(REQUIRED) line > (3) the SSLCIPH line > > N.B. The number of lines between (1) & (2) may vary, > while (3) usually follow (2). > > Please help. > Thanks If the below isn't what you want, provide smore more info on how to select the lines you want output.
From: Ed Morton on 25 Feb 2010 15:41 On Feb 25, 2:16 pm, Harry <harryooopot...(a)hotmail.com> wrote: > I have about 30 text files containing some MQ object definitions. > I want to locate some CHANNEL definitions with a pattern > "SSLCAUTH(REQUIRED)". > > For example: > > $ find . -type f -exec grep -l SSLCAUTH\(REQUIRED\) {} \; > ./host1/Q_MANAGER1.log > ./host1/Q_MANAGER2.log > ./host2/Q_MANAGER3.log > ./host2/Q_MANAGER4.log > ./host3/Q_MANAGER5.log > ./host3/Q_MANAGER6.log > ... > > The text before and after the pattern are like this : > > DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + > * ALTDATE (2009-07-24) + > * ALTTIME (23.03.53) + > TRPTYPE(TCP) + > DESCR(' ') + > HBINT(300) + > MAXMSGL(4194304) + > MCAUSER(' ') + > RCVDATA(' ') + > RCVEXIT(' ') + > SCYDATA(' ') + > SCYEXIT(' ') + > SENDDATA(' ') + > SENDEXIT(' ') + > SSLCAUTH(REQUIRED) + > SSLCIPH(' ') + > SSLPEER(' ') + > KAINT(AUTO) + > MONCHL(QMGR) + > COMPMSG(NONE) + > COMPHDR(NONE) + > REPLACE > > DEFINE QUEUE <blablabla> > ... > > What I want is a shell cmd that can print (for each channel > definition inside a Q_MANAGER log) : > (1) the DEFINE CHANNEL line before the pattern > (2) the SSLCAUTH(REQUIRED) line > (3) the SSLCIPH line > > N.B. The number of lines between (1) & (2) may vary, > while (3) usually follow (2). > > Please help. > Thanks If the below isn't what you want, provide some more info on how to select the lines you want output. Ed. $ cat file Some preceeding records DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + * ALTDATE (2009-07-24) + * ALTTIME (23.03.53) + TRPTYPE(TCP) + DESCR(' ') + HBINT(300) + MAXMSGL(4194304) + MCAUSER(' ') + RCVDATA(' ') + RCVEXIT(' ') + SCYDATA(' ') + SCYEXIT(' ') + SENDDATA(' ') + SENDEXIT(' ') + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + SSLPEER(' ') + KAINT(AUTO) + MONCHL(QMGR) + COMPMSG(NONE) + COMPHDR(NONE) + REPLACE DEFINE QUEUE <blablabla> $ awk 'BEGIN{RS="";ORS="\n\n";FS=OFS="\n"} /SSLCAUTH\(REQUIRED\)/{print $1,$15,$16}' file DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + SSLCAUTH(REQUIRED) + SSLCIPH(' ') +
From: Ed Morton on 25 Feb 2010 15:48 On Feb 25, 2:41 pm, Ed Morton <mortons...(a)gmail.com> wrote: > On Feb 25, 2:16 pm, Harry <harryooopot...(a)hotmail.com> wrote: > > > > > > > I have about 30 text files containing some MQ object definitions. > > I want to locate some CHANNEL definitions with a pattern > > "SSLCAUTH(REQUIRED)". > > > For example: > > > $ find . -type f -exec grep -l SSLCAUTH\(REQUIRED\) {} \; > > ./host1/Q_MANAGER1.log > > ./host1/Q_MANAGER2.log > > ./host2/Q_MANAGER3.log > > ./host2/Q_MANAGER4.log > > ./host3/Q_MANAGER5.log > > ./host3/Q_MANAGER6.log > > ... > > > The text before and after the pattern are like this : > > > DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + > > * ALTDATE (2009-07-24) + > > * ALTTIME (23.03.53) + > > TRPTYPE(TCP) + > > DESCR(' ') + > > HBINT(300) + > > MAXMSGL(4194304) + > > MCAUSER(' ') + > > RCVDATA(' ') + > > RCVEXIT(' ') + > > SCYDATA(' ') + > > SCYEXIT(' ') + > > SENDDATA(' ') + > > SENDEXIT(' ') + > > SSLCAUTH(REQUIRED) + > > SSLCIPH(' ') + > > SSLPEER(' ') + > > KAINT(AUTO) + > > MONCHL(QMGR) + > > COMPMSG(NONE) + > > COMPHDR(NONE) + > > REPLACE > > > DEFINE QUEUE <blablabla> > > ... > > > What I want is a shell cmd that can print (for each channel > > definition inside a Q_MANAGER log) : > > (1) the DEFINE CHANNEL line before the pattern > > (2) the SSLCAUTH(REQUIRED) line > > (3) the SSLCIPH line > > > N.B. The number of lines between (1) & (2) may vary, > > while (3) usually follow (2). > > > Please help. > > Thanks > > If the below isn't what you want, provide some more info on how to > select the lines you want output. > > Ed. > > $ cat file > Some preceeding records > > DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + > * ALTDATE (2009-07-24) + > * ALTTIME (23.03.53) + > TRPTYPE(TCP) + > DESCR(' ') + > HBINT(300) + > MAXMSGL(4194304) + > MCAUSER(' ') + > RCVDATA(' ') + > RCVEXIT(' ') + > SCYDATA(' ') + > SCYEXIT(' ') + > SENDDATA(' ') + > SENDEXIT(' ') + > SSLCAUTH(REQUIRED) + > SSLCIPH(' ') + > SSLPEER(' ') + > KAINT(AUTO) + > MONCHL(QMGR) + > COMPMSG(NONE) + > COMPHDR(NONE) + > REPLACE > > DEFINE QUEUE <blablabla> > $ awk 'BEGIN{RS="";ORS="\n\n";FS=OFS="\n"} > /SSLCAUTH\(REQUIRED\)/{print $1,$15,$16}' file > DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + > SSLCAUTH(REQUIRED) + > SSLCIPH(' ') +- Hide quoted text - > > - Show quoted text - ....for example, if it's based on the text in each field then the solution you want might be along the lines of: $ awk 'BEGIN{RS="";FS="\n"} /SSLCAUTH\(REQUIRED\)/{ for (i=1;i<=NF;i++) if ($i ~ /DEFINE|SSLCAUTH|SSLCIPH/) print $i print "" }' file DEFINE CHANNEL ('AAA.SVRCONN') CHLTYPE(SVRCONN) + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + Regards, Ed.
From: Harry on 25 Feb 2010 15:59 On Feb 25, 12:41 pm, Ed Morton <mortons...(a)gmail.com> wrote: > On Feb 25, 2:16 pm, Harry <harryooopot...(a)hotmail.com> wrote: [snip] > $ awk 'BEGIN{RS="";ORS="\n\n";FS=OFS="\n"} > /SSLCAUTH\(REQUIRED\)/{print $1,$15,$16}' file Ed, thanks for the suggestion. But $1,$15,$16 would not work for all occurances, since I mentioned "the number of lines between [1st line] & [search patter line] may vary. Here is a sample input. -- xx.txt -- begin -- DEFINE CHANNEL ('CH_A') CHLTYPE(SVRCONN) + * ALTDATE (2009-11-24) + * ALTTIME (03.46.04) + TRPTYPE(TCP) + DESCR(' ') + HBINT(300) + MAXMSGL(4194304) + MCAUSER('mqm') + RCVDATA(' ') + RCVEXIT(' ') + SCYDATA(' ') + SCYEXIT(' ') + SENDDATA(' ') + SENDEXIT(' ') + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + SSLPEER(' ') + KAINT(AUTO) + MONCHL(QMGR) + COMPMSG(NONE) + COMPHDR(NONE) + REPLACE DEFINE CHANNEL ('CH_B') CHLTYPE(CLUSRCVR) + * ALTDATE (2009-08-17) + * ALTTIME (07.31.49) + TRPTYPE(TCP) + BATCHINT(0) + BATCHHB(0) + BATCHSZ(50) + CLUSTER('SomeCluster') + CLUSNL(' ') + CONNAME('some.host(15390)') + LOCLADDR(' ') + CONVERT(NO) + DESCR('Cluster receiver channel for someCluster') + DISCINT(6000) + HBINT(300) + LONGRTY(999999999) + LONGTMR(1200) + SHORTRTY(10) + SHORTTMR(60) + MAXMSGL(4194304) + MCATYPE(THREAD) + MCAUSER(' ') + MRDATA(' ') + MREXIT(' ') + MRRTY(10) + MRTMR(1000) + MSGDATA(' ') + MSGEXIT(' ') + NETPRTY(0) + NPMSPEED(FAST) + PUTAUT(DEF) + RCVDATA(' ') + RCVEXIT(' ') + SCYDATA(' ') + SCYEXIT(' ') + SENDDATA(' ') + SENDEXIT(' ') + SEQWRAP(999999999) + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + SSLPEER(' ') + KAINT(AUTO) + MONCHL(QMGR) + STATCHL(QMGR) + CLWLPRTY(0) + CLWLRANK(0) + CLWLWGHT(50) + COMPMSG(NONE) + COMPHDR(NONE) + REPLACE -- xx.txt -- end -- $ awk 'BEGIN{RS="";ORS="\n\n";FS=OFS="\n"} /SSLCAUTH\(REQUIRED\)/ {print $1,$15, $16}' xx.txt DEFINE CHANNEL ('CH_A') CHLTYPE(SVRCONN) + SSLCAUTH(REQUIRED) + SSLCIPH(' ') + DEFINE CHANNEL ('CH_B') CHLTYPE(CLUSRCVR) + HBINT(300) + LONGRTY(999999999) + $ The 1st occurance is OK, while the 2nd is not. Any further suggestion ?
|
Next
|
Last
Pages: 1 2 3 4 Prev: jmanage start/stop init.d bash script Next: Escaping regexp meta characters |