sed -ne '/<!--/ { :c; /-->/! { N; b c; }; /-->/s/<!--.*-->//g }; /^ *$/!p;'
You might consider stripping blanklines and/or filtering through xmllint
--format to make the xml pretty printed.
Sun, 14 Jan 2007Strip XML comments with sed
sed -ne '/<!--/ { :c; /-->/! { N; b c; }; /-->/s/<!--.*-->//g }; /^ *$/!p;'
You might consider stripping blanklines and/or filtering through xmllint
--format to make the xml pretty printed.
Comments: 2 (view comments)
2 responses to 'Strip XML comments with sed'
Ananya Bhaduri posted at Fri Jan 18 14:50:30 2008...
Hi,
cat $moduleDepsFile \ | sed -ne "/<!--/ { :c; /-->/! { N; b c; }; /-->/s/<!--.*-->//g }; /^ *$/!p;" > $moduleDepsF ile.stripped I am using this command to strip xml comments and it appears to work on linux; i tried to port the same code on solaris and the commands fails saying sed: Label too long: /<\!--/ { :c; /-->/\! { N; b c; }; /-->/s/<\!--.*-->//g }; /^ *$/\!p; Please help..
Ananya Bhaduri posted at Wed Jan 23 16:47:40 2008...
oh btw the solution is install gnu sed, much more powerful.
Leave a reply
You need javascript enabled to use this form. Anti-spam efforts ongoing. Also,
if the comment doesn't show up, it's because the form expired. Go back and copy
your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm
just playing with antispam methods right now. If this insists on not working,
please email me about it.
|
Search this siteNavigationMetadataHome About Resume My Code (SVN)ArticlesARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work EfficiencyProjectsfex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scriptsPresentationsYahoo! Hack Day '06 Unix Essentials Vi/Vim EssentialsTag CloudCalendar
FriendsBarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler ShieldsTechnorati |
|||||||||||||||||||||||||||||||||||||||||||||||||