From: Shell Solution on 26 Dec 2007 09:55 Hi, I have a file that looks like this: <MOID> 1 2 2 </MOID> <MOID> 3 4 5 </MOID> <MOID> 4 5 6 </MOID> ---------------------------------------------------------------------------------------- And I want to convert it to this: moid1,1 moid1,2 moid1,2 moid2,3 moid2,4 moid2,5 moid3,4 moid3,5 moid3,6 Please advise.
From: Janis Papanagnou on 26 Dec 2007 10:11 Shell Solution wrote: > Hi, > I have a file that looks like this: > > <MOID> > 1 > 2 > 2 > </MOID> > <MOID> > 3 > 4 > 5 > </MOID> > <MOID> > 4 > 5 > 6 > </MOID> > > > ---------------------------------------------------------------------------------------- > > And I want to convert it to this: > > moid1,1 > moid1,2 > moid1,2 > > moid2,3 > moid2,4 > moid2,5 > > moid3,4 > moid3,5 > moid3,6 > > > Please advise. awk '/^<M/{m++}/[0-9]/{print "moid"m ","$1}/^<\//{print ""}' your_file Janis
From: mik3l3374 on 26 Dec 2007 22:01 On Dec 26, 10:55 pm, Shell Solution <esoimeme.geo...(a)gmail.com> wrote: > Hi, > I have a file that looks like this: > > <MOID> > 1 > 2 > 2 > </MOID> > <MOID> > 3 > 4 > 5 > </MOID> > <MOID> > 4 > 5 > 6 > </MOID> > > ---------------------------------------------------------------------------------------- > > And I want to convert it to this: > > moid1,1 > moid1,2 > moid1,2 > > moid2,3 > moid2,4 > moid2,5 > > moid3,4 > moid3,5 > moid3,6 > > Please advise. if you have GNU awk awk 'BEGIN{RS="</MOID>\n<MOID>|<MOID>|</MOID>"} { for ( i=1 ; i<=NF;i++) print "moid"m,$i m++ }' file
From: Shell Solution on 14 Jan 2008 03:24 Dear All, I appreciate your responses, it has been helpful. So here is the real deal. Please find blow the content of 1 of the 24 files i receive daily,and I meant to perform text extraction on. ------------------------------------------------------------------------------------- Actual Input ------------------------------------------------------------------------------------- <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl" ?> <!DOCTYPE mdc SYSTEM "MeasDataCollection.dtd"> <mdc xmlns:HTML="http://www.w3.org/TR/REC-xml"> <mfh> <ffv>1</ffv> <sn></sn> <st>INAT</st> <vn>MITMEDIA</vn> <cbt>20080114102500.2+0300</cbt> </mfh> <md> <neid> <neun></neun> <nedn></nedn> </neid> <mi> <mts>20080114103000.1+0300</mts> <gp>300</gp> <mt>TCAP_TPS</mt> <mt>TCAP_COMPONENT_SENT</mt> <mt>TCAP_COMPONENT_RECEIVED</mt> <mt>MTP2_MSU_SENT</mt> <mt>MTP2_MSU_RECEIVED</mt> <mt>MTP2_LINK_LOAD</mt> <mt>MTP2_LINK_LOAD_SENT</mt> <mt>MTP2_LINK_LOAD_RECEIVED</mt> <mt>SAAL_SDUS_SENT</mt> <mt>SAAL_OCTETS_SENT</mt> <mt>SAAL_OCTETS_RECEIVED</mt> <mt>SAAL_LINK_LOAD_RECEIVED</mt> <mt>SAAL_LINK_LOAD_SENT</mt> <mv> <moid>SigMeas=InstanceId=2,HSN=0,SDL=2, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>36.71</r> <r>38.28</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=InstanceId=1,HSN=0,SDL=2, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>36.84</r> <r>38.41</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=InstanceId=4,HSN=0,SDL=1, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>0.00</r> <r>0.00</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=InstanceId=3,HSN=0,SDL=1, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>0.00</r> <r>0.00</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=InstanceId=2,HSN=0,SDL=1, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>36.93</r> <r>38.16</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=InstanceId=1,HSN=0,SDL=1, Source = SS7</moid> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r>36.88</r> <r>38.01</r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=DEFAULT, Source = SS7</moid> <r>118.19</r> <r>32982</r> <r>22633</r> <r>20367</r> <r>26581</r> <r>175.49</r> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv><mv> <moid>SigMeas=DEFAULT, Source = _SYSTEM</moid> <r>118.19</r> <r>32982</r> <r>22633</r> <r>20367</r> <r>26581</r> <r>175.49</r> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <r></r> <sf>FALSE</sf></mv></mi> </md> <mff> <ts>20080114103000.1+0300</ts> </mff> </mdc> ------------------------------------------------------------------------------------- Desired Output ------------------------------------------------------------------------------------- InstanceId=2 36.71 38.28 InstanceId=1 36.84 38.41 InstanceId=4 0 0 InstanceId=3 0 0 InstanceId=2 36.93 38.16 InstanceId=1 36.88 38.01 DEFAULT 118.19 32982 22633 20367 26581 175.49 DEFAULT 118.19 32982 22633 20367 26581 175.49 On Dec 26 2007, 5:55 pm, Shell Solution <esoimeme.geo...(a)gmail.com> wrote: > Hi, > I have a file that looks like this: > > <MOID> > 1 > 2 > 2 > </MOID> > <MOID> > 3 > 4 > 5 > </MOID> > <MOID> > 4 > 5 > 6 > </MOID> > > ---------------------------------------------------------------------------------------- > > And I want to convert it to this: > > moid1,1 > moid1,2 > moid1,2 > > moid2,3 > moid2,4 > moid2,5 > > moid3,4 > moid3,5 > moid3,6 > > Please advise.
From: Cyrus Kriticos on 14 Jan 2008 15:55 Shell Solution wrote: > > I appreciate your responses, it has been helpful. > So here is the real deal. > > Please find blow the content of 1 of the 24 files i receive daily,and > I meant to perform text extraction on. sed -ne 's#.*s=\([a-zA-Z0-9=]*\),.*#\1#p' -e 's#<r>\(.*\)</r>#\1#p' filename -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country.
|
Pages: 1 Prev: zsh+OSX: how to cope w spaces in fnames? Next: Filtering two files with uncommon column |