I'm having a custom xml and im trying to replace a multiple occurring string (say "uuidVariable") with a unique UUID each in Bash.
<dict>
<key>Apple</key>
<true/>
<key>uuid</key>
<string>uuidVariable</string>
</dict>
<dict>
<key>Banana</key>
<false/>
<key>uuid</key>
<string>uuidVariable</string>
</dict>
I'm able to generate a UUID and store it :
UUID=$(cat /proc/sys/kernel/random/uuid)
But how is it possible to loop through myfile.xml and replace each string with a new UUID?
I know how to count the occurring string, but i don't think this is gonna help me further
countUUID=$(sed 's/uuidVariable/uuidVariable\n/g' myfile.xml | grep -c "uuidVariable")
EDIT: Also i know how to replace 2 strings.. but thats not solving the problem having each unique.
sed -i s/uuidVariable/UUID/g myfile.xml