regex - Match some regular expressions in specific lines and save those lines to an array in bash -


i need scan lines of text file specific tags , store whatever between tags array in bash. basic syntax follows:

<description> "long, multiline text descriptions" </description> 

where text in between gets stored in array.

this implementation requires xmlstarlet (http://xmlstar.sourceforge.net/) , assumes no eot (end-of-transmission) characters exist within contents. has advantages associated being based on real xml parser -- entities processed, comments ignored, cdata interpreted literally, etc.

descriptions=() while ifs='' read -r -d $'\x04';   descriptions+=( "$reply" ) done < <(xmlstarlet sel -m -t -v //description -o $'\x04') 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -