I've two variables. One is the text with placeholders e.g. &a or &B. The other one contains the variables which should be inserted in the text. &a says it's the first word, &b says it's the second word. In the text they could be in random order. Delimiter is a whitespace. How could I do this in bash?
Example:
TEXT="Once &B a &a"
VAR="time upon"
# Result should be "Once upon a time"