file.txt has multiple occurrences of the word 'dummy' and the goal is to replace each occurrence of such word by a novel UUID.
I was wondering if there is a solution for this using a single-line command, but if not I would like the simplest possible bash script. For example, something in line with:
sed -i "s/dummy/$(uuidgen)/g" file.txt
unfortunately this command substitutes every word 'dummy' by the same uuid.
e.g.
Input:
{
{"myid":"dummy"},
{"myid":"ymmud"},
{"myid":"dummy"},
{"myid":"ymmud"},
{"myid":"dummy"},
{"myid":"ymmud"}
}
expected output:
{
{"myid":"79769E7B-BED5-4CB5-AEF9-CCE445D9212E"},
{"myid":"ymmud"},
{"myid":"F2FDDD4A-4800-4F0F-911A-FEDBC82915DD"},
{"myid":"ymmud"},
{"myid":"52D93565-81E9-479C-8BD9-457754581BBE"},
{"myid":"ymmud"}
}