Pulling out a value

<configuration> <password>foo &amp; bar</password> </configuration> EOF $ password="$(xml_grep --text_only '/configuration/password' ./test.xml)" $ printf '%s\n' "$password" foo & bar ```

Pulling out a value#

Probably the most common use case for transforming XML in Bash is pulling out a simple value such as a configuration item. When doing so you need to be careful that any XML escaping is undone – you’ll want any &NAME; characters replaced by their literals in your script. xml_grep is one tool which can do this:


This page is a preview of The newline Guide to Bash Scripting

No discussions yet