xml - Search for a string but search another set of strings before and after that -
i trying search string "logfatal2sys" search string "valnamelist" before , after , put comment tag before , after lines of "valnamelist" lines. basically, there many "valnamelist" blocks inside xml need comment out portion of xml using set of unix commands. can me?
<valnamelist xmlns="http://www.oblix.com" listname="logfatal2sys"> <namevalpair paramname="log_level" value="loglevel_fatal"> </namevalpair> <namevalpair paramname="log_writer" value="syslogwriter"> </namevalpair> <namevalpair paramname="log_status" value="on"> </namevalpair> </valnamelist>
ok, understand need comment out these xml blocks. can using sed command following:
cat your_xml_file | sed 's/<valnamelist>/<!-- <valnamelist>/g' | sed 's/<\/valnamelist>/<\/valnamelist>-->/g'
this looks every valnamelist block , insert xml comment start @ beginning, , same block closing.
Comments
Post a Comment