I wanted to grab some variables from an xml and parse them into environment variables. After some googling around, I found my answer: Use xmlstarlet to pull the name/value pairs Then use sed to combine them into "name=value" format Then use a while loop with process substitution It ended up being something like #!/bin/bash while read -r line; do # do some stuff to parse the line # ... printf -v $varname "$varval" export $varname done <<< "$(xmlstarlet sel -t -m "[xml selections here]" -v . -n <[xml file] | sed 'N;s/\n/=/')" Yay so cool.
Views are my own.