regex - How to uncomment an xml node from the command line? -


the regex select desired node like:

<!--\s*<env-entry>(.*\s*)*</env-entry>\s*--> 

where xml file contains:

<!--     <env-entry>        <env-entry-name>solr/home</env-entry-name>        <env-entry-value>/put/your/solr/home/here</env-entry-value>        <env-entry-type>java.lang.string</env-entry-type>     </env-entry>    --> <!--     <other-entry>     </other-entry>    --> 

how uncomment selected node (probably sed/awk)?

here crude solution, might have bugs @ corner cases, test out carefully:

/<!--/ {     comment = $0     getline     if ($0 !~ /<env-entry>/) print comment }  /-->/ {     if (last_line ~ /<\/env-entry>/) next }  {     last_line = $0     print } 

update: forgot mention solution in awk, in case.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -