SED:Extract particular string

Posted: September 16, 2010 in sed

xml.txt:

<ZNT><BFGIN=”1″><FDI_DC40 SFGMFNT=”1″><AAANAM>FDI_DC40</AAANAM><MANDT>400</MANDT>
<DOC>89834777783439</DOC><DOCRFL>640</DOCRFL><STATUS>30</STATUS><DIRFCT>1</DIRFCT>
<OUTMOD>2</OUTMOD><IDOCTYP>INOTIF01</IDOCTYP><CIMTYP>ZNT</CIMTYP>
<QMDAT>00000000</QMDAT><MZFIT>000000</MZFIT><ZF1SNHD SFGMFNT=”1″><QMNUM>100013698222</QMNUM>
<PARNUM>CSN</PARNUM><SOURCF>SAP-P01400</SOURCF><VBFLN>0936451491</VBFLN></ZF1SNHD>
<F1NTITM SFGMFNT=”1″><FFNUM>0001</FFNUM><OTGRP>DISPOSN</OTGRP><OTFIL>OR01</OTFIL>
SOLUTION:
sed -e ‘s/.*<DOC/<DOC/;s^</DOC>.*><VBFLN^</DOC><VBFLN^;s^</VBFLN>.*^</VBFLN>^’ xml.txt |\
grep -i doc

OUTPUT: <DOC>89834777783439</DOC><VBFLN>0936451491</VBFLN>

Hello world!

Posted: September 16, 2010 in Uncategorized

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!