"sed" ignoring last line

Hi,

I am giving below command script and getting below output. I tried using "sed" which is ignoring 4th line. Can you please help me to get the expected output like below
Code:

echo "dis clusqmgr(*) cluster(BT.CL.OFSSTAT4) conname qmtype deftype"| runmqsc -e $QMGR|egrep 'CHANNEL|QMTYPE|CLUSQMGR|CONNAME|DEFTYPE'|sed -e 's/CLUSQMGR(/+/g'|sed -e 's/CLUSQMGR(/+/g'|tr -d "\n"|tr "+" "\n"

Getting Output:

Please note QMTYPE(REPOS) is coming down and then again SU* is coming in next line

SU.QM.EMB70xtx)                CHANNEL(OFSSTAT4.EMB70xtx.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.N9.70.x0(Tx43x))   DEFTYPE(CLUSSDRA) 
QMTYPE(REPOS)
SU.QM.EMB70xtN)                CHANNEL(OFSSTAT4.EMB70xtN.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.N9.70.xx(Tx43N))   DEFTYPE(CLUSSDRB)
 QMTYPE(REPOS)
SU.QM.OFSMMxTx)                CHANNEL(OFSSTAT4.OFSMMxTx.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.x88.T8.9x(Tx43x))   DEFTYPE(CLUSSDRA)
 QMTYPE(NORMAL)
SU.QM.OFSMMxTN)                CHANNEL(OFSSTAT4.OFSMMxTN.Cx)   CLUSTER(SU.CL.OFSSTAT4)                 CONNAME(x0.x88.T8.94(Tx43N))   DEFTYPE(CLUSRCVR)                       
QMTYPE(NORMAL)

Expecting output:

SU.QM.EMB70xtx,                 OFSSTAT4.EMB70xtx.Cx,    SU.CL.OFSSTAT4,                  x0.N9.70.x0,Tx43x,    CLUSSDRA,                        REPOS,
SU.QM.EMB70xtN,                 OFSSTAT4.EMB70xtN.Cx,    SU.CL.OFSSTAT4,                  x0.N9.70.xx,Tx43N,    CLUSSDRB,                        REPOS,
SU.QM.OFSMMxTx,                 OFSSTAT4.OFSMMxTx.Cx,    SU.CL.OFSSTAT4,                  x0.x88.T8.9x,Tx43x,    CLUSSDRA,                        NORMAL,
SU.QM.OFSMMxTN,                 OFSSTAT4.OFSMMxTN.Cx,    SU.CL.OFSSTAT4,                  x0.x88.T8.94,Tx43N,    CLUSRCVR,                        NORMAL,

Hi

For the input content you specified, try this:

$ sed 'N;s/\n/ /' file | awk -F'[)(]' '{for(i=1;i<=NF;i+=2)printf "%s,",$i;print"";}'

Guru.

 
sed -e 's/) CHANNEL(/, /g' -e 's/) CLUSTER(/, /g' -e 's/) CONNAME(/, /g' -e 's/(Tx/,Tx/g' -e 's/)) DEFTYPE(/, /g' -e 's/) QMTYPE(/, /g' -e 's/)/,/g' 

@guruprasad:

I tried belwo one and didn't get anyoutput

echo "dis clusqmgr(*) cluster(BT.CL.OFSSTAT4) conname qmtype deftype"| runmqsc -e $QMGR|egrep 'CHANNEL|QMTYPE|CLUSQMGR|CONNAME|DEFTYPE'|sed 'N;s/\n/ /' file | awk -F'[)(]' '{for(i=1;i<=NF;i+=2)printf "%s,",$i;print"";}'

got below error

ksh: syntax error: `;' unexpected 

I know this is lengthy one :frowning:

# sed -e 's/)/,/g' -e 's/(//g' -e 's/CHANNEL//g' -e 's/CLUSTER//g' -e 's/CONNAME//g' -e 's/DEFTYPE//g' -e 's/QMTYPE//g' -e 's/Tx4
3/,Tx43/g' -e 's/,,/,/g' file

@Sathya: I didn't get anyoutput for below one

echo "dis clusqmgr(*) cluster(BT.CL.OFSSTAT4) conname qmtype deftype"| runmqsc -e $QMGR|egrep 'CHANNEL|QMTYPE|CLUSQMGR|CONNAME|DEFTYPE'|
sed -e 's/)/,/g' -e 's/(//g' -e 's/CHANNEL//g' -e 's/CLUSTER//g' -e 's/CONNAME//g' -e 's/DEFTYPE//g' -e 's/QMTYPE//g' -e 's/Tx4 3/,Tx43/g' -e 's/,,/,/g'


Given the output file from your first post, try this:

$ sed 'N;s:\n: :;s:)::g;s: *[A-Z]*(:, :g' file
SU.QM.EMB70xtx, OFSSTAT4.EMB70xtx.Cx, SU.CL.OFSSTAT4, x0.N9.70.x0, Tx43x, CLUSSDRA, REPOS
SU.QM.EMB70xtN, OFSSTAT4.EMB70xtN.Cx, SU.CL.OFSSTAT4, x0.N9.70.xx, Tx43N, CLUSSDRB, REPOS
SU.QM.OFSMMxTx, OFSSTAT4.OFSMMxTx.Cx, SU.CL.OFSSTAT4, x0.x88.T8.9x, Tx43x, CLUSSDRA, NORMAL
SU.QM.OFSMMxTN, OFSSTAT4.OFSMMxTN.Cx, SU.CL.OFSSTAT4, x0.x88.T8.94, Tx43N, CLUSRCVR, NORMAL

It first appends the next line and removes the <newline> char as you seem to have a two line input, then removes closing parentheses, then replaces all blanks followed by upper case chars followed by an opening parenthesis by <comma><space>. Adapt the number of spaces (or replace by <TAB>) if need be.

Can you please share the output of the below

echo "dis clusqmgr(*) cluster(BT.CL.OFSSTAT4) conname qmtype deftype"| runmqsc -e $QMGR|egrep 'CHANNEL|QMTYPE|CLUSQMGR|CONNAME|DEFTYPE'