My problem in here is I want to write the value for $i on a specific lines in the config.xml, see below structure of config.xml. Also I want all the lines to be one below another not in same line.
#!/bin/bash
NAME_ID=( User1 User2 User3 )
USER_CONF=/opt/test/config.xml
for i in "${NAME_ID[@]}"; do
printf '<user><id>ID</id><name><%s/name></user>\n' "$i" >> "$EXTERNAL_USER_CONF"
done
config.xml structure below(I want to insert all three lines one below another where it says USER_TO_INSER_HERE but instead I get them in the end):
<company type="external">
<enabled>true</enabled>
<users type="allowed">
USER_TO_INSERT_HERE
</users>
</company>
<domain><id>ID</id><name><User1/name></domain>
<domain><id>ID</id><name><User2/name></domain>
<domain><id>ID</id><name><User3/name></domain>
What I would expect to be the final result is:
<company type="external">
<enabled>true</enabled>
<users type="allowed">
<domain><id>ID</id><name><User1/name></domain>
<domain><id>ID</id><name><User2/name></domain>
<domain><id>ID</id><name><User3/name></domain>
</users>
</company>